【问题标题】:Aapt_rules.txt not found when building apk in android studio在android studio中构建apk时找不到Aapt_rules.txt
【发布时间】:2017-08-01 06:24:30
【问题描述】:

在运行 proguard 构建我的 apk 文件时,我收到以下错误:

Warning:Exception while processing task java.io.FileNotFoundException: C:\Users\Josh\Documents\AdscendUnityPlugin2.1.3\AdscendUnityPlugin2.1.3\HelloUnity\Export\HelloUnity\build\intermediates\proguard-rules\debug\aapt_rules.txt (The system cannot find the path specified)

我的 gradle 文件:

// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'
    }
}

allprojects {
   repositories {
       jcenter()
      flatDir {
        dirs 'libs'
      }
   }
}

apply plugin: 'com.android.application'

repositories {

    maven { url "https://bitbucket.org/adscend/androidsdk/raw/master/" }
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.adscendmedia.sdk:adscendmedia:2.1.26'
}

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.0'

    defaultConfig {
        targetSdkVersion 25
    }

    lintOptions {
        abortOnError false
    }

    buildTypes {
        debug {
            jniDebuggable true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'

        }
    }

}

我似乎也找不到文件夹“proguard-rules”,是什么导致了这个错误? 有什么想法吗?

我知道我正在调试版本中运行 proguard,我只是想让它在这一点上工作。

谢谢

【问题讨论】:

  • 我也面临同样的问题。可能是在最新版本的 Gradle 插件中导致此问题。第一次看到这样的问题。当我使用 Gradle 插件版本 2.3.0 升级 Android Studio 时遇到此问题
  • 同样,我还没有找到解决方法。

标签: android android-studio gradle proguard


【解决方案1】:

在我的情况下,我的自定义 proguard.pro 是空白的。 重建项目对我有用。

【讨论】:

  • '干净的项目'是关键。
【解决方案2】:

就我而言,问题是这样的:
我有一个包含多个模块的项目:一个 android 应用程序和一个 android 库。

当我在 Android Studio 中构建 assembleRelease 时,我还必须确保所有内容都是为 release(而不是 debug)构建的。

在 Android Studio 中将Build Variant 设置为发布:

在库模块的build.gradle文件中:

android {
    defaultPublishConfig "release"

另见:

【讨论】:

    【解决方案3】:

    我认为你的 proguard-pro.txt 可能是空白的。我之前也遇到过这种问题。在 proguard-pro.txt 中添加以下代码后,它对我有用。只需尝试一次,它可能对你有用。

    # Add project specific ProGuard rules here.
    # By default, the flags in this file are appended to flags specified
    # in D:\Android\adt-bundle-windows-x86-20140702\adt-bundle-windows-x86-20140702\sdk/tools/proguard/proguard-android.txt
    # You can edit the include path and order by changing the proguardFiles
    # directive in build.gradle.
    #
    # For more details, see
    #   http://developer.android.com/guide/developing/tools/proguard.html
    
    # Add any project specific keep options here:
    
    # If your project uses WebView with JS, uncomment the following
    # and specify the fully qualified class name to the JavaScript interface
    # class:
    #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
    #   public *;
    #}
    # Required for GSON
    -keep class com.ptechsolutions.android.authenticrecipe.core.** { *; }
    
    -keepattributes *Annotation*
    -keepattributes Signature
    -keep class sun.misc.Unsafe { *; }
    
    -keep class * extends java.util.ListResourceBundle {
        protected Object[][] getContents();
    }
    
    -keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
        public static final *** NULL;
    }
    
    -keepnames @com.google.android.gms.common.annotation.KeepName class *
    -keepclassmembernames class * {
        @com.google.android.gms.common.annotation.KeepName *;
    }
    
    -keepnames class * implements android.os.Parcelable {
        public static final ** CREATOR;
    }
    
    
    -keep class butterknife.** { *; }
    -dontwarn butterknife.internal.**
    -keep class **$$ViewInjector { *; }
    
    -keepclasseswithmembernames class * {
        @butterknife.* <fields>;
    }
    
    -keepclasseswithmembernames class * {
        @butterknife.* <methods>;
    }
    -dontwarn org.apache.commons.**
    -dontwarn com.google.**
    -dontwarn com.j256.ormlite**
    -dontwarn org.apache.http**
    
    -keepattributes SourceFile,LineNumberTable
    -keep class com.j256.**
    -keepclassmembers class com.j256.** { *; }
    -keep enum com.j256.**
    -keepclassmembers enum com.j256.** { *; }
    -keep interface com.j256.**
    -keepclassmembers interface com.j256.** { *; }
    
    -keepattributes Signature
    # GSON Library
    # For using GSON @Expose annotation
    -keepattributes *Annotation*
    
    # Gson specific classes
    -keep class sun.misc.Unsafe { *; }
    #-keep class com.google.gson.stream.** { *; }
    
    # Application classes that will be serialized/deserialized over Gson
    -keep class com.google.gson.examples.android.model.** { *; }
    
    -keepattributes SourceFile, LineNumberTable
    
    # Google Map
    -keep class com.google.android.gms.maps.** { *; }
    -keep interface com.google.android.gms.maps.** { *; }
    
    -keep class org.apache.harmony.awt.** { *; }
    -dontwarn org.apache.harmony.awt.**
    
    -keep class com.github.siyamed.** { *; }
    -dontwarn com.github.siyamed.**
    
    -keep class com.squareup.picasso.** { *; }
    -dontwarn com.squareup.picasso.**
    
    -keep class com.squareup.okhttp.** { *; }
    -dontwarn com.squareup.okhttp.**
    
    -keep class com.sun.mail.** { *; }
    -dontwarn com.sun.mail.**
    
    -keep class org.codehaus.mojo.** { *; }
    -dontwarn org.codehaus.mojo.**
    
    -keep class java.awt.datatransfer.** { *; }
    -dontwarn java.awt.datatransfer.**
    
    -keep class java.nio.file.** { *; }
    -dontwarn java.nio.file.**
    
    -keep class javax.mail.** { *; }
    -dontwarn javax.mail.**
    
    -keep class com.theartofdev.edmodo.** { *; }
    -dontwarn com.theartofdev.edmodo.**
    
    -keep class javax.activation.** { *; }
    -dontwarn javax.activation.**
    
    -dontskipnonpubliclibraryclassmembers
    

    【讨论】:

      【解决方案4】:

      删除 Moudle 中的文件夹build 并重建。

      在你的项目中是HelloUnity\build\ 文件夹

      【讨论】:

        猜你喜欢
        • 2018-02-23
        • 2022-10-25
        • 2020-04-30
        • 1970-01-01
        • 2017-09-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-04-24
        相关资源
        最近更新 更多