Android Studio无法生成APK

问题描述 投票:3回答:1

我有一个奇怪的问题,它只是从现有的Android Studio 2.3.3项目开始的。

生成过程不会自动生成APK,在这种情况下,app-debug.apk日志显示生成成功,但项目目录树中的任何位置都没有APK。但是,手动选择Build / Build APK可以正常工作。

当我更改源并单击运行时,这是一个问题。构建过程成功,但是将“错误安装APK”放入模拟器(因为APK不存在)。

此问题仅在一个项目上发生,而我之前在玩Espresso。我的猜测是我在某处更改了设置,只是无法确定是哪一个。我需要更改什么才能再次自动生成APK?包括build.gradle。

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
    applicationId "com.example.myapp"
    minSdkVersion 16
    targetSdkVersion 25
    versionCode 2
    versionName "0.0.2"
    vectorDrawables.useSupportLibrary = true
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

signingConfigs {
    release {
        storeFile file("/home/user/keystore/keystore.jks")
        storePassword "xxxxxxxxxxxxxxxxxx"
        keyAlias "xxxxxxxxxxxxxxxxx"
        keyPassword "xxxxxxxxxxxxxxxxxxx"
    }
}

buildTypes {
    release {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.release
    }
}
lintOptions {
    abortOnError false
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android.gms:play-services-ads:10.2.4'
compile 'com.google.android.gms:play-services-location:10.2.4'
testCompile 'junit:junit:4.12'
}
android android-studio android-gradle-plugin build.gradle
1个回答
0
投票

[由于Build.gradle中存在许多依赖关系,因此android studio需要太多时间,然后说请求超时。因此,请看Build.gradle。执行这些步骤。

第一种方法:尝试最小化依赖项

第二方法:添加MultiDEX implementation 'androidx.multidex:multidex:2.0.1',用于androidX。

第三方法:制作类public class ApplicationDelegate extends MultiDexApplication { },然后在Application标签中像这样在Android清单文件中添加

<application
        android:name=".ApplicationDelegate"
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        tools:ignore="AllowBackup,GoogleAppIndexingWarning">


Hope it will solve your issue!



© www.soinside.com 2019 - 2024. All rights reserved.