当前位置:   article > 正文

Android开发错误——Android Studio中遇到过的错误问题与解决方案汇总_run configuration app is not supported in the curr

run configuration app is not supported in the current project. cannot obtain

(1)编译时发生

  1. Error:(25, 0) Gradle DSL method not found: 'compile()'
  2. Possible causes:<ul><li>The project 'AP' may be using a version of Gradle that does not contain the method.
  3. <a href="openGradleSettings">Gradle settings</a></li><li>The build file may be missing a Gradle plugin.
  4. <a href="apply.gradle.plugin">Apply Gradle plugin</a></li>


解决方法:

1、在最外层的Gradle中,删除如下的语句

  1. dependencies {
  2. compile files('libs/xUtils-2.6.14.jar')
  3. }


(2)编译时发生

  1. Error:(25, 0) Gradle DSL method not found: 'android()'
  2. Possible causes:<ul><li>The project 'AP' may be using a version of Gradle that does not contain the method.
  3. <a href="openGradleSettings">Gradle settings</a></li><li>The build file may be missing a Gradle plugin.
  4. <a href="apply.gradle.plugin">Apply Gradle plugin</a></li>


解决方法:

1、在最外层的Gradle中,删除如下的语句

  1. android {
  2. compileSdkVersion 23
  3. buildToolsVersion '23.0.2'
  4. }


(3)编译时发生

  1. Error:(1, 0) Your project path contains non-ASCII characters. This will most likely cause the build to fail on Windows. Please move your project to a different directory. See http://b.android.com/95744 for details. This warning can be disabled by using the command line flag -Dcom.android.build.gradle.overridePathCheck=true, or adding the line com.android.build.gradle.overridePathCheck=true' to gradle.properties file in the project directory.
  2. <a href="openFile:D:\workspacebackup\我的框架\AP\app\build.gradle">Open File</a>


解决方法:

1、你的项目中存在中文命名,将项目中对应的中文命名改为英文即可


(4)编译时发生

  1. Error:Execution failed for task ':app:mergeDebugResources'.
  2. > D:\workspace5\Boke\app\src\main\res\drawable\custom_Animation_progress_bar.xml: Error: 'A' is not a valid file-based resource name character: File-based resource names must contain only lowercase a-z, 0-9, or underscore


解决方法:

1、你的项目中res\drawable下存在大写字母,将项目中对应的大写字母改为小写字母即可


(5)在Aidl文件进行编译时发生

  1. Error:Execution failed for task ':app:compileDebugAidl'.
  2. > java.lang.RuntimeException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'E:\Eclipse\android-studio-sdk\android-sdk-windows\build-tools\23.0.2\aidl.exe'' finished with non-zero exit value 1


解决方法:

1、项目的编译版本和编译工具的版本不一致,右键项目 open Moudle Setting -> app -> 修改Compile Sdk Version 和Build Tools Version 版本一致

2、可能是你的复制进来的Aidl文件的包名没有修改成当前的包名


(6)在复制权限内容,进行编译时发生

  1. Error:Execution failed for task ':yuyin:processDebugResources'.
  2. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'E:\Eclipse\android-studio-sdk\android-sdk-windows\build-tools\23.0.2\aapt.exe'' finished with non-zero exit value 1

解决方法:

1、就是xml 可能出现无法识别的资源文件错误, 就是资源文件 里面出错了

2、有时候在uses-permission中多了个空格也会报这个错误


(7)run程序时发生

Error running app: Instant Run requires 'Tools | Android | Enable ADB integration' to be enabled.


解决方法:

1、勾选中下图选项即可



(8)在配置NDK后编译时发生

  1. Error:Execution failed for task ':app:compileDebugNdk'.
  2. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'E:\Eclipse\android-studio-sdk\android-sdk-windows\ndk-bundle\ndk-build.cmd'' finished with non-zero exit value 2


解决方法:

1、编译NDK时最好不要使用SDKManager里下载的ndk-bundle,否则会报这些错误

2、官网下载NDK开发包,r9、r10系列,然后替换掉久的ndk就可以了


(9)在Android Studio->run的时候发生

  1. Unable to create Debug Bridge: Unable to start adb server: error: could not install *smartsocket* listener: cannot bind to 127.0.0.1:5037: 通常每个套接字地址(协议/网络地址/端口)只允许使用一次。 (10048)
  2. could not read ok from ADB Server
  3. * failed to start daemon *
  4. error: cannot connect to daemon
  5. 'E:\Eclipse\android-studio-sdk\android-sdk-windows\platform-tools\adb.exe,start-server' failed -- run manually if necessary


解决方法:

1、网上的方案,亲测不是这个问题

根据提示查看adb的端口号5037被谁占用,通过 netstat -aon|findstr “5037” 找出相应的pid号,再通过任务管理器找到相应pid号的进程,然后将其结束,最后重启adb

2、将原本选择的默认adb换成我们自己的sdk里面的adb,亲测成功了


(10)创建了两个Module,其中一个Module依赖另一个Module而导致了出现该问题,如果在Android Studio中,有ModuleA和ModuleB,我们希望ModuleA依赖ModuleB,运行时候可能会出现该问题

Error:Dependency Boke:zXingProj:unspecified on project app3 resolves to an APK archive which is not supported as a compilation dependency. File: D:\workspace5\Boke\zXingProj\build\outputs\apk\zXingProj-release-unsigned.apk


解决方法:

1、查看被依赖的ModuleB的build.gradle,里面可以看到

apply plugin: 'com.android.application'  
将这一句改为即可
apply plugin: 'com.android.library'  
接着会出现另一个错误
Error:Library projects cannot set applicationId. applicationId is set to 'com.dtr.zxing' in default config.

解决方法:

1、需要将builde.gradle — android — defaultConfig中的applicationId删除


(11)这个问题是我在修改Bmob的最新jar包的时候发生的错误,从3.4.6换到3.5.0时,编译出错

Error:Execution failed for task ':app:transformClassesWithDexForRelease'. > com.android.build.api.tr


解决方案:

1、jar包冲突(finished with non-zero exit value 2) 
主要表现为编译后出现 finished with non-zero exit value 2错误,原因是jar包冲突,导致的原因可能是在dependencies中使用compile files()导入一次jar包,然后有其它jar的引入方式使用compile’com.xxx’方式,正好又引用了这个jar包,所以导致了重复引用jar包的冲突。最常见的是support-v4包的重复引用

(12)当在gradle导入第三方依赖(sweetalert)之后,编译出错

  1. Error:Execution failed for task ':qq:processDebugManifest'.
  2. > Manifest merger failed : Attribute application@icon value=(@mipmap/ic_launcher) from AndroidManifest.xml:45:9-43
  3. is also present at [com.pnikosis:materialish-progress:1.0] AndroidManifest.xml:13:9-45 value=(@drawable/ic_launcher).
  4. Suggestion: add 'tools:replace="android:icon"' to <application> element at AndroidManifest.xml:42:5-122:19 to override.


解决方案:

1、由于导入的第三方依赖也使用我们application的icon值的属性,具体修改步骤如下图,加上下面圈起来的语句



(13)Git Push 提交到Github上发生错误

  1. $ git push origin master
  2. To https://github.com/AndroidHensen/NewsTemplate.git
  3. ! [rejected] master -> master (fetch first)
  4. error: failed to push some refs to 'https://github.com/AndroidHensen/NewsTemplate.git'
  5. hint: Updates were rejected because the remote contains work that you do
  6. hint: not have locally. This is usually caused by another repository pushing
  7. hint: to the same ref. You may want to first integrate the remote changes
  8. hint: (e.g., 'git pull ...') before pushing again.
  9. hint: See the 'Note about fast-forwards' in 'git push --help' for details.


解决方案:

1、出现的主要原因是,本地没有update到最新版本的项目(git上有README.md文件没下载下来)

2、先进行代码合并,git pull --rebase origin master,再进行代码提交,git push -f origin master


(14)升级完Android Studio2.3后,打包release出现的错误

  1. Error:Execution failed for task ':qq:lintVitalRelease'.
  2. > Lint found fatal errors while assembling a release target.
  3. To proceed, either fix the issues identified by lint, or modify your build script as follows:
  4. ...
  5. android {
  6. lintOptions {
  7. checkReleaseBuilds false
  8. // Or, if you prefer, you can continue to check for errors in release builds,
  9. // but continue the build even when errors are found:
  10. abortOnError false
  11. }
  12. }
  13. ...


解决方法:

在app的build.gradle中添加如下代码,重新Generate Signed APK即可

  1. android{
  2. lintOptions {
  3. checkReleaseBuilds false
  4. abortOnError false
  5. }
  6. }





声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/119231
推荐阅读
相关标签
  

闽ICP备14008679号