PS:换新版本的AS后,打包aar后,到Unity里编译APK报了很多错/捂脸,特此总结
工具:Unity2018.4.36 AS2020.3
AS打包AAR以及常见报错
ps:假如你已下载AS2020.3.1并且已经配置好了sdk以及jdk
1.新建Project
File-New Project-Empty Activity
2.以默认app模块作为Module,编译aar需要该模块
在该Module内我们需要修改以下几处
1. build.gradle
修改后如下
plugins {
// id 'com.android.application'
id 'com.android.library'
}
android {
compileSdk 30
defaultConfig {
// applicationId "com.example.myapplication"
minSdk 21
targetSdk 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
这里'com.android.library' 才能编译aar,需要是library库
2.AndroidMainfest.xml文件
特别说明:以下修改xml去掉了MainActivity模块以及MainActivity.java文件。只编译第三方工具aar包。如需要MainActivity可参考我的下一篇文章 这里
3. 修改res目录
这里把两个themes.xml 的


