用minifyEnabled = true在设备上运行的路径null
当我尝试在物理设备上运行我的应用程序时,出现错误路径可能不为空或空字符串。 path ='null'在项目的构建阶段,但构建运行很好,如果我尝试在模拟器上运行应用程序。用minifyEnabled = true在设备上运行的路径null
我做了一些实验,我发现这种行为是由于minifyEnabled = true,但我还没有找到一种方法来了解哪些路径为空以及为什么。
有没有人已经解决了这样的问题?
这是我的build.gradle文件
buildscript { repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
repositories {
maven { url 'https://maven.fabric.io/public' }
}
import com.android.build.OutputFile;
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'io.fabric'
apply plugin: 'let'
apply plugin: "org.sonarqube"
Properties localProperties = new Properties()
try {
localProperties.load(project.rootProject.file('local.properties').newDataInputStream())
} catch (Exception e) {
localProperties = null
}
def versionMajor = 0 // Max one digit
def versionMinor = 2 // Max one digit
def versionPatch = 6 // Max one digit
def versionBuild = 6 // Max two digits: bump for dogfood builds, public betas, etc.
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
renderscriptTargetApi 17
renderscriptSupportModeEnabled true
versionCode versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100 + versionBuild
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
multiDexEnabled true
dataBinding {
enabled = true
}
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments disableAnalytics: 'true' // Analytics opt-out.
}
productFlavors {
envProd {
applicationId "xxx"
buildConfigField("String", "API_KEY", "xxx")
crashlytics {
enableNdk true
androidNdkOut 'build/intermediates/transforms/mergeJniLibs/envProd/release/folders/2000/1f/main/lib/'
androidNdkLibsOut 'build/intermediates/transforms/stripDebugSymbol/envProd/release/folders/2000/1f/main/lib'
}
}
envTest {
applicationId "xxx"
buildConfigField("String", "API_KEY", "xxx")
crashlytics {
enableNdk true
androidNdkOut 'build/intermediates/transforms/mergeJniLibs/envTest/release/folders/2000/1f/main/lib/'
androidNdkLibsOut 'build/intermediates/transforms/stripDebugSymbol/envTest/release/folders/2000/1f/main/lib'
}
}
}
signingConfigs {
release {
if (localProperties != null) {
storeFile file(localProperties['store.file'])
storePassword localProperties['store.password']
keyAlias localProperties['key.alias']
keyPassword localProperties['key.password']
}
}
}
buildTypes {
all {
buildConfigField "java.util.Date", "BUILD_DATE", "new java.util.Date(" + System.currentTimeMillis() + "L)"
}
debug {
applicationIdSuffix ".debug"
ext.enableCrashlytics = false // Disable fabric build ID generation for debug builds
ndk {
abiFilters = []
abiFilters.addAll(['armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'])
}
}
release {
signingConfig signingConfigs.release
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-crashlytics.pro',
'proguard-rules.pro',
'proguard-support-v7-appcompat.pro',
'proguard-google-play-services.pro',
'proguard-eventbus.pro',
'proguard-let.pro',
'proguard-gson.pro',
'proguard-guava.pro',
'proguard-aws.pro',
'proguard-calligraphy.pro'
ndk {
abiFilters = []
abiFilters.addAll(['armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'])
}
}
}
splits {
abi {
enable true
reset()
include 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
universalApk false
}
}
packagingOptions {
pickFirst 'lib/armeabi-v7a/libopencv_imgproc.so'
pickFirst 'lib/armeabi-v7a/libopencv_core.so'
pickFirst 'lib/arm64-v8a/libopencv_imgproc.so'
pickFirst 'lib/arm64-v8a/libopencv_core.so'
pickFirst 'lib/x86/libopencv_imgproc.so'
pickFirst 'lib/x86/libopencv_core.so'
pickFirst 'lib/x86_64/libopencv_imgproc.so'
pickFirst 'lib/x86_64/libopencv_core.so'
}
dataBinding {
enabled = true
}
testOptions.unitTests.all {
testLogging { // Always show the result of every unit test, even if it passes.
events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
}
}
}
dependencies {
compile project('xxx')
compile project('xxx')
compile project('xxx')
envTestCompile project('xxx')
envProdCompile project('xxx')
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.crashlytics.sdk.android:crashlytics:[email protected]') {
transitive = true;
}
compile('com.crashlytics.sdk.android:crashlytics-ndk:[email protected]') {
transitive = true;
}
// Testing
androidTestCompile('com.android.support.test:runner:0.5') {
exclude module: 'support-annotations'
}
// Set this dependency to use JUnit 4 rules
androidTestCompile('com.android.support.test:rules:0.5') {
exclude module: 'support-annotations'
}
// Set this dependency to build and run Espresso tests
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') {
exclude module: 'support-annotations'
}
// Set this dependency to build and run UI Automator tests
androidTestCompile('com.android.support.test.uiautomator:uiautomator-v18:2.1.2') {
exclude module: 'support-annotations'
}
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.google.android.gms:play-services-vision:11.0.4'
compile 'com.google.android.gms:play-services-location:11.0.4'
compile 'com.google.android.gms:play-services-safetynet:11.0.4'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.github.bumptech.glide:glide:3.8.0'
compile 'jp.wasabeef:glide-transformations:2.0.2'
compile 'com.google.guava:guava:19.0'
compile 'com.googlecode.libphonenumber:libphonenumber:8.3.1'
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.github.paolorotolo:appintro:4.1.0'
compile 'com.facebook.rebound:rebound:0.3.8'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.amazonaws:aws-android-sdk-core:2.6.11'
compile 'com.amazonaws:aws-android-sdk-s3:2.6.11'
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-core:1.3'
androidTestCompile 'org.mockito:mockito-core:1.10.19'
androidTestCompile 'com.crittercism.dexmaker:dexmaker:1.4'
androidTestCompile 'com.crittercism.dexmaker:dexmaker-dx:1.4'
androidTestCompile 'com.crittercism.dexmaker:dexmaker-mockito:1.4'
}
// map for the version code, max 2 digits
project.ext.abiCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3, 'mips': 5, 'mips64': 6, 'x86': 8, 'x86_64': 9]
android.applicationVariants.all { variant ->
// assign different version code for each output
variant.outputs.each { output ->
output.versionCodeOverride =
(variant.mergedFlavor.getMinSdkVersion().getApiLevel() * 10000000
+ project.ext.abiCodes.get(output.getFilter(OutputFile.ABI)) * 100000
+ variant.mergedFlavor.versionCode)
}
}
这是错误的完整堆栈跟踪:
java.lang.IllegalArgumentException: path may not be null or empty string. path='null' at org.gradle.api.internal.file.BaseDirFileResolver.doResolve(BaseDirFileResolver.java:72)
at org.gradle.api.internal.file.AbstractFileResolver.resolve(AbstractFileResolver.java:79)
at org.gradle.api.internal.file.AbstractFileResolver.resolve(AbstractFileResolver.java:61)
at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext$FileCollectionConverter.convertInto(DefaultFileCollectionResolveContext.java:173)
at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.doResolve(DefaultFileCollectionResolveContext.java:134)
at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.resolveAsFileCollections(DefaultFileCollectionResolveContext.java:92)
at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext$FileCollectionConverter.convertInto(DefaultFileCollectionResolveContext.java:157)
at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.doResolve(DefaultFileCollectionResolveContext.java:109)
at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.resolveAsFileCollections(DefaultFileCollectionResolveContext.java:92)
at org.gradle.api.internal.file.CompositeFileCollection.getSourceCollections(CompositeFileCollection.java:172)
at org.gradle.api.internal.file.CompositeFileCollection.visitRootElements(CompositeFileCollection.java:184)
at org.gradle.api.internal.changedetection.state.AbstractFileCollectionSnapshotter.snapshot(AbstractFileCollectionSnapshotter.java:78)
at org.gradle.api.internal.changedetection.rules.AbstractNamedFileSnapshotTaskStateChanges.buildSnapshots(AbstractNamedFileSnapshotTaskStateChanges.java:87)
at org.gradle.api.internal.changedetection.rules.AbstractNamedFileSnapshotTaskStateChanges.<init>(AbstractNamedFileSnapshotTaskStateChanges.java:54)
at org.gradle.api.internal.changedetection.rules.InputFilesTaskStateChanges.<init>(InputFilesTaskStateChanges.java:28)
at org.gradle.api.internal.changedetection.rules.TaskUpToDateState.<init>(TaskUpToDateState.java:55)
at org.gradle.api.internal.changedetection.changes.DefaultTaskArtifactStateRepository$TaskArtifactStateImpl.getStates(DefaultTaskArtifactStateRepository.java:164)
at org.gradle.api.internal.changedetection.changes.DefaultTaskArtifactStateRepository$TaskArtifactStateImpl.isUpToDate(DefaultTaskArtifactStateRepository.java:79)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:236)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:228)
at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:228)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:215)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:77)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:58)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:32)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:113)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
at org.gradle.initialization.DefaultGradleLauncher$3.execute(DefaultGradleLauncher.java:196)
at org.gradle.initialization.DefaultGradleLauncher$3.execute(DefaultGradleLauncher.java:193)
at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:193)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:119)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:102)
at org.gradle.launcher.exec.GradleBuildController.run(GradleBuildController.java:71)
at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:50)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.tooling.internal.provider.runner.RunAsBuildOperationBuildActionRunner$1.execute(RunAsBuildOperationBuildActionRunner.java:43)
at org.gradle.tooling.internal.provider.runner.RunAsBuildOperationBuildActionRunner$1.execute(RunAsBuildOperationBuildActionRunner.java:40)
at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
at org.gradle.tooling.internal.provider.runner.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:40)
at org.gradle.tooling.internal.provider.runner.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:75)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)
at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:49)
at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:44)
at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:29)
at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:47)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
at org.gradle.util.Swapper.swap(Swapper.java:38)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
回答:
尝试删除这个:
Properties localProperties = new Properties() try {
localProperties.load(project.rootProject.file('local.properties').newDataInputStream())
} catch (Exception e) {
localProperties = null
}
这:
signingConfigs { release {
if (localProperties != null) {
storeFile file(localProperties['store.file'])
storePassword localProperties['store.password']
keyAlias localProperties['key.alias']
keyPassword localProperties['key.password']
}
}
}
并尝试手动签署构建
以上是 用minifyEnabled = true在设备上运行的路径null 的全部内容, 来源链接: utcz.com/qa/265418.html