导入 walle 报如下错误:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':app'. at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:79) at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:72) at org.gradle.configuration.project.LifecycleProjectEvaluator.access$600(LifecycleProjectEvaluator.java:53) at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate.run(LifecycleProjectEvaluator.java:198) at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402) at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:394) at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165) at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250) at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158) at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:92) at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31) at org.gradle.configuration.project.LifecycleProjectEvaluator$EvaluateProject$1.run(LifecycleProjectEvaluator.java:111) at org.gradle.internal.Factories$1.create(Factories.java:25)
解决如下:
点击三后 新建一个 config,在里面配置你的 keystore 和 别名 密码等。最后点击 ok。
配置完后 在 app 下的 gradle 中会出现如下:
signingConfigs { config { storeFile file('C:\\Users\\Administrator\\Desktop\\345\\Project\\CarSteward\\app\\CarSteward.jks') storePassword 'nulicarsteward' keyAlias = 'CarSteward' keyPassword 'nulicarsteward' } }
接着看一下你的 build.gradle 中有没有buildTypes{} 这样的一个闭包。如果有 或者没有,修改为如下:
buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' signingConfig signingConfigs.config } }
最主要的就是最后面这就话,也就是我们刚才配置的 config 。如果没有这句,则会报 配置 app 项目是出现问题
整个 build.gradle 文件如下:
apply plugin: 'com.android.application' apply plugin: 'walle' android { compileSdkVersion 29 buildToolsVersion "29.0.2" defaultConfig { applicationId "com.testdemo.www.myapplication" minSdkVersion 14 targetSdkVersion 29 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } signingConfigs { config { storeFile file('C:\\Users\\Administrator\\Desktop\\345\\Project\\Tinker\\keystore.jks') storePassword '123456789' keyAlias = 'key0' keyPassword '123456789' } } walle { // 指定渠道包的输出路径 apkOutputFolder = new File("${project.buildDir}/outputs/channels"); // 定制渠道包的APK的文件名称 apkFileNameFormat = '${appName}-${channel}-${buildType}-v${versionName}-${versionCode}.apk'; // 渠道配置文件 channelFile = new File("${project.getProjectDir()}/channel") } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' signingConfig signingConfigs.config } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' implementation 'com.meituan.android.walle:library:1.1.6' }