標籤:dir dso .net lease 內容 sdn 原來 def 3.0
1. File -> New -> New Module -> Android Library 例子中暫命名ModuleA
2. 修改剛建立 ModuleA下的build.gradle
android條目下添加 publishNonDefault true (否則build檔案夾下不會有編譯好的jar檔案夾及檔案)
3. 如果有其他依賴jar檔案,放在ModuleA lib檔案夾內,並在dependance 下添加連結路徑
dependencies { implementation fileTree(include: [‘*.jar‘], dir: ‘libs‘) testImplementation ‘junit:junit:4.12‘ implementation ‘com.android.support:appcompat-v7:28.0.0-alpha3‘ androidTestImplementation ‘com.android.support.test:runner:1.0.2‘ androidTestImplementation ‘com.android.support.test.espresso:espresso-core:3.0.2‘ implementation files(‘libs/xxx-classes.jar‘)}
4. 添加如下代碼
task clearJar(type: Delete) { delete ‘build/libs/xyz.jar‘////這行表示如果你已經打過一次包了,再進行打包則把原來的包刪掉}task makeJar(type: Copy) { from(‘build/intermediates/intermediate-jars/release/‘) //這行表示要打包的檔案的路徑,根據下面的內容,其實是該路徑下的classes.jar into(‘build/libs/‘) //這行表示打包完畢後包的產生路徑,也就是產生的包存在哪 include(‘classes.jar‘) //看到這行,如果你對分包有瞭解的話,你就可以看出來這行它只是將一些類打包了 rename (‘classes.jar‘, ‘xyz.jar‘)}makeJar.dependsOn(clearJar, build)
註:粉色框內的檔案夾名字可能會隨AS版本不同有所差異
5. 找到此檔案夾下的makeJar,雙擊,編譯後就會在ModuleA 下的 build/libs/目錄內找到編譯好的 xyz.jar
6 如果想此檔案用在unity3d中,只需要丟到unity3d Assets/Plugins目錄下
參考:https://stackoverflow.com/questions/43039532/no-release-bundle-folder-after-upgrading-android-studio
53406390
AndroidStudio 3 export jar file