Aapt_rules.txt not found when building apk in andr

2019-02-04 11:34发布

问题:

When running proguard to build my apk file, I get the following error:

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)

My gradle file:

// 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'

        }
    }

}

I couldn't seem to find the folder 'proguard-rules' either, what could be causing this error? Any ideas?

I am aware i'm running proguard on my debug build, i'm just trying to get it to work at this point.

Thank you

回答1:

In my case my custom proguard.pro is blank. Rebuild project works for me.



回答2:

In my case the problem was this:
I have a project with several modules: one android application and one android library.

When I build assembleRelease in Android Studio, I must also make sure that everything is built for release (not debug).

In Android Studio set the Build Variant to release:

In the build.gradle file of the library module:

android {
    defaultPublishConfig "release"

see also:

  • https://developer.android.com/studio/projects/android-library.html
  • https://code.google.com/p/android/issues/detail?id=52962


回答3:

I think your proguard-pro.txt may be blank. I had this kind of problem earlier. Bu after adding below code in proguard-pro.txt it worked for me. Just try it once, it may work for you.

# 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:

Delete the folder build in Moudle and rebuild.

In you project is HelloUnity\build\ folder