当运行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,我只是想让它在这一点上运行。
谢谢
答案 0 :(得分:30)
在我的情况下,我的自定义proguard.pro是空白的。 重建项目适合我。
答案 1 :(得分:2)
就我而言,问题是这样的:
我有一个包含几个模块的项目:一个android应用程序和一个android库。
当我在Android Studio中构建assembleRelease
时,我还必须确保所有内容都是为发布(而不是 debug )构建的。
在Android Studio中设置要发布的Build Variant
:
在库模块的build.gradle
文件中:
android {
defaultPublishConfig "release"
另见:
答案 2 :(得分:0)
我认为你的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
答案 3 :(得分:0)
删除Moudle中的文件夹build
并重建。
在您的项目中是HelloUnity\build\
文件夹