无法在最新的android studio 3.0.1上构建应用程序

时间:2017-12-14 05:37:22

标签: android android-studio build proguard

有没有人经历过从3.0.1构建应用程序并且它不会运行?

我觉得这个人遇到的问题与我的相同; Unable to Build Release Apk Android Studio 3.0.1 Proguard-Rules

我的应用程序还有**(尝试按照上面的建议应用解决方案)我的proguard规则,我无法删除它们,因为这会导致应用程序无法构建。

请帮助我(b)

更新2

结果的为我工作的解决方案请参阅下面的答案

https://stackoverflow.com/a/47809116/4767606



更新1

我能够在下面申请Wahdat Kashmiri的答案;调试版本运行正常但是当切换构建版本时,应用程序只运行直到启动屏幕然后崩溃。

implementation  fileTree(include: ['*.jar'], dir: 'libs')
implementation ('com.android.support:appcompat-v7:25.3.1') {
   transitive = true;
}
implementation ('de.keyboardsurfer.android.widget:crouton:1.8.5@aar') {
   exclude group: 'com.google.android', module: 'support-v4'
}
implementation('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
   transitive = true;
}
implementation('org.apache.httpcomponents:httpmime:4.3') {
   exclude module: "httpclient"
}
implementation('com.nispok:snackbar:2.11.+') {
   exclude group: 'com.google.android', module: 'support-v4'
}
implementation 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
implementation 'com.facebook.android:facebook-android-sdk:4.26.0'
implementation 'com.android.support:multidex:1.0.2'
implementation 'org.jsoup:jsoup:1.10.2'
implementation 'com.android.volley:volley:1.0.0'
implementation 'com.firebaseui:firebase-ui-auth:3.1.0'
implementation 'com.google.code.gson:gson:2.8.1'
implementation 'com.shamanland:fonticon:0.1.9'
implementation 'com.victor:lib:1.0.4'
implementation 'com.google.guava:guava:23.3-android'
implementation 'org.bouncycastle:bcprov-jdk16:1.46'
implementation 'commons-codec:commons-codec:1.10'
implementation 'org.altbeacon:android-beacon-library:2.9.1'
implementation 'ly.count.android:sdk:16.06.04'
implementation 'net.danlew:android.joda:2.9.9.1'
implementation 'com.azoft.carousellayoutmanager:carousel:1.2.1'
implementation 'com.squareup.okhttp3:okhttp:3.9.1'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
implementation 'com.rollbar:rollbar-android:0.2.1'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.google.android.gms:play-services-maps:11.4.2'
implementation 'com.google.android.gms:play-services-location:11.4.2'
implementation 'com.google.android.gms:play-services-auth:11.4.2'
implementation 'com.google.android.gms:play-services-analytics:11.4.2'
implementation 'com.google.firebase:firebase-appindexing:11.4.2'
implementation 'com.google.firebase:firebase-messaging:11.4.2'

3 个答案:

答案 0 :(得分:1)

的build.gradle

 apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.techno.giants.json"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

Build.gradle roject

 buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

答案 1 :(得分:1)

在我的情况下,我能够通过为jsoup添加缺少的proguard规则来解决我的问题。这很奇怪,因为之前我不需要添加它。检查您的库可能需要添加新规则。

答案 2 :(得分:0)

几周后我面临同样的问题。我通过添加这个proguard规则解决了这个问题:

-keepattributes SourceFile,LineNumberTable
-keep class com.parse.*{ *; }
-dontwarn com.parse.**
-dontwarn com.squareup.picasso.**
-keepclasseswithmembernames class * {
    native <methods>;
} 
-ignorewarnings

并确保通过实施&amp;替换所有编译所有testCompile都是通过testImplementation。