8. AndroidStudio Unsupported Modules Detected问题
- 1, Unsupported Modules Detected: Compilation is not supported for following modules
原因: 将项目挪了一个目录后重新打开出现.
解决: 用AndroidStudio打开后 , 将.idea和.gradle删掉 , 再选择file->Invalidata Caches / Restart
…
或者
- 2, run的时候出现Error:please select Android SDK
原因: git项目第一次打开时出现.
解决: Tools -> Android -> Sync Project with Gradle Files或者菜单栏中Gradle带个上下带箭头的图标(这个是上述步骤的快捷图标)
参考
7. sdk version
6. Android Studio Export Jar
apply plugin: 'com.android.library'
task deleteOldJar(type: Delete){
delete 'build/outputs/test.jar'
}
task exportJar(type: Copy){
from('build/intermediates/bundles/release/')
into('build/libs/')
include('classes.jar')
rename('classes.jar','test.jar')
}
exportJar.dependsOn(deleteOldJar,build)
studio选择Gradle->Tasks->other->exportJar 双击
5, Android Studio出现The selected directory is not a valid home for android
参考
最后也就是在导入的时候不选择/sdk/platform/具体的某个版本,而是选择整个android-sdk目录就可以了。
4, compileDebugJavaWithJavac
错误描述:
Execution failed for task ':app:compileDebugJavaWithJavac'
参考
解决:
在teriminal运行gradle compileDebufJavaWithJavac
结果如下:
com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0
修改根目录下的gradle依赖
dependencies {
classpath ‘com.android.tools.build:gradle:3.4.0-alpha09’
}
再将gradle/wrapper/gradle-wrapper.properties改成对应的版本
distributionUrl=https://services.gradle.org/distributions/gradle-5.1-milestone-1-all.zip
结果还是不行
后面百度说需要把buildversion和completeversion保持一至才行.
看编译警告
WARNING: The specified Android SDK Build Tools version (26.0.3) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.4.0-alpha09.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '26.0.3'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
Remove Build Tools version and sync project
Affected Modules: app, providerlib, upgradelib, usbcomm
重新把根目录的build.gradle改低.
同时把wrapper下的配置改低.
重新build
3,gradlew command not found
参考
引起原因:gradlew不在系统全局变量路径中,当执行命令时会报错,提示找不到。
解决方法1:使用 ./指定当前目录,如: ./gradlew :upay_plugi:build
解决方法2:配置全局环境变量
a)找到gradle文件所在路径。该文件可在Android Studio安装目录下找到,如:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/bin
b)配置.bash_profile文件。如:
export PATH=${PATH}:/Applications/Android\ Studio.app/Contents/gradle/gradle-2.14.1/bin
2 , ndk配置支持c代码提示和跳转
在lib工程的build.gradle里添加build配置
ndk:配置里用来控制需要支持的abi
externalNativeBuild:可以让androidstudio至此c代码之间的提示和跳转.
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk{
moduleName "native_jni"
abiFilters "armeabi-v7a","arm64-v8a","armeabi","x86"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
ndkBuild{
path 'src/main/jni/Android.mk'
}
}
}