随时可能更新,更具体的可看官网
Gradle plugin和Gradle版本可在File——Project Structure中查看,需要保证上面的最低版本对应
将Jar复制到libs,然后右键选择Add As Library
检查gradle user home是否为默认目录
按照提示点击Add google Maven repository and sync project
A problem occurred configuring root project 'OTA'.
> Could not resolve all files for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:8.0.0.
Required by:
project :
> No matching variant of com.android.tools.build:gradle:8.0.0 was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.0' but:
- Variant 'apiElements' capability com.android.tools.build:gradle:8.0.0 declares a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares a component for use during compile-time, compatible with Java 11 and the consumer needed a component for use during runtime, compatible with Java 8
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '8.0')
- Variant 'javadocElements' capability com.android.tools.build:gradle:8.0.0 declares a component for use during runtime, and its dependencies declared externally:
- Incompatible because this component declares documentation and the consumer needed a library
- Other compatible attributes:
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Doesn't say anything about org.gradle.plugin.api-version (required '8.0')
- Variant 'runtimeElements' capability com.android.tools.build:gradle:8.0.0 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '8.0')
- Variant 'sourcesElements' capability com.android.tools.build:gradle:8.0.0 declares a component for use during runtime, and its dependencies declared externally:
- Incompatible because this component declares documentation and the consumer needed a library
- Other compatible attributes:
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Doesn't say anything about org.gradle.plugin.api-version (required '8.0')
上面报错关键为组件在JDK11编译,当前环境为Java8
Incompatible because this component declares a component for use during compile-time, compatible with Java 11 and the consumer needed a component for use during runtime, compatible with Java 8
点击File——Project Structure
点击Gradle Settings,选择大于11的SDK(我选择的是17)
修改build.gralde(app),将dependencies中的compile改为implementation
help-Change Memory Settings修改堆的大小
在gradle-wrapper.properties设置堆和元空间大小
org.gradle.jvmargs=-Xmx8192m -XX:MaxPermSize=1024m
怎么改都溢出,最后发现是导入的AOSP的Framework.jar中的java文件参与了运行,将implementation改为compileOnly
compileOnly files('libs\\classes.jar')
谷歌商店上架应用API不小于XX,可在build.gralde(app)的andoird配置里添加lintOptions取消检查
android {
......
lintOptions{
checkReleaseBuilds false
abortOnError false
}
......
}
确保File-Project Structure中的JDK大于1.8
build.gradle添加如下设置
android {
......
compileOptions{
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}