![](/img/trans.png)
[英]Using Android Studio how do I get a signed, non-debug and zip aligned APK?
[英]Android Studio: How can I get the aligned signed release APK?
我正在使用Android Studio,而對於其他項目,當我嘗試生成已簽名的APK時,我會得到app-release.apk
文件,而且還有任何問題。
但是在這個特定的項目中,我只能得到一個app-release-unaligned.apk
文件。
與我的其他項目的主要區別在於使用transloadit jar和org.apache.httpcomponents庫,我必須在我的graddle文件中寫下packagingOptions字段。
這是我的build.grade文件
apply plugin: 'com.android.application'
android {
signingConfigs {
}
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.bambinotes.bambinotessnap"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
zipAlignEnabled true
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENCE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: 'httpclient'
}
compile files('libs/transloadit-1.0.2.jar')
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.anupcowkur:reservoir:2.0'
compile 'com.android.support:cardview-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.mcxiaoke.volley:library:1.0.16'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
compile 'com.android.support:support-v4:22.2.0'
}
**更新**
我剛剛發現我遇到的錯誤是什么,Android Studio在另一個文件夾中打開finder,生成app-debug和app-release-unaligned文件(我們可以將其視為中間文件), app-release.apk文件是目錄結構中的兩個文件夾。
即使我因為知道我的麻煩的原因而感到尷尬,但我會留下這個問題,看看將來是否會發生這種情況。
app-release.apk文件位於應用程序文件夾中。
有時Android Studio會顯示未對齊文件所在的另一個目錄,因此您只需查找新創建的文件即可。
您需要將簽名配置添加到Gradle文件,有關詳細信息,請參閱此答案如何使用Gradle創建發布的簽名apk文件?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.