Error: cannot set readonly: proguardFiles property for class: com.android.build.gradle.managed.BuildType

I am trying to run an example AR application from: https://artoolkit.org/documentation/doku.php?id=4_Android:android_examples

I tried to open the ARSimpleProj project. But this gives me this error:

Error:Cannot set readonly property: proguardFiles for class: com.android.build.gradle.managed.BuildType 

I am using Android Studio 2.2.2 and Gradle 2.14.1

Thanks!

+5
source share
3 answers

I got the same error the last few hours. I decided to change the assembly type as follows:

 buildTypes { release { minifyEnabled false proguardFiles 'proguard-rules.pro' } } 

After that, I deleted the entire imported line of ndk code. So my build.gradle for aRimple is

 apply plugin: 'com.android.model.application' model { android { compileSdkVersion = 23 buildToolsVersion = "23.0.1" defaultConfig.with { applicationId = "org.artoolkit.ar.samples.ARSimple" minSdkVersion.apiLevel = 15 targetSdkVersion.apiLevel = 22 versionCode = 1 //Integer type incremented by 1 for every release, major or minor, to Google store versionName = "1.0" //Real fully qualified major and minor release description buildConfigFields.with { //Defines fields in the generated Java BuildConfig class, in this case, for create() { //default config, that can be accessed by Java code type = "int" //eg "if (1 == BuildConfig.VALUE) { /*do something*/}". name = "VALUE" //See: [app or lib]/build/generated/source/buildConfig/[package path]/ value = "1" // BuildConfig.java } } } } buildTypes { release { minifyEnabled false proguardFiles 'proguard-rules.pro' } } android.productFlavors { } } dependencies { //compile 'com.android.support:support-v4:23.0.1' //compile 'com.android.support:appcompat-v7:23.0.1' //Only required when the target device API level is greater than compile project(':aRBaseLib') } //the compile and target of the app being deployed to the device 

Then I create and copy the entire .so library file to the jnilibs folder in the main application folder, as shown in the figure

fig

Then run yours. I do not know what this solution is for this. But errors go, and the project starts without errors. Tell me if you find any other solution for this. Thanks.

+7
source

According to this description , in version 0.4.0, '+ =' was chosen and use ".add ()" for it instead. So make an expression

proguardFiles += file('proguard-rules.pro')

change to

proguardFiles.add(file('proguard-rules.pro'))

and the error will disappear

The build.gradle file now looks like this: pay attention to the changes. Made 2-3 changes but now it works absolutely fine. Code below: -

  apply plugin: 'com.android.model.application' model { android { compileSdkVersion = 23 buildToolsVersion = "23.0.2" defaultConfig.with { applicationId = "org.artoolkit.ar.samples.ARSimple" minSdkVersion.apiLevel = 15 targetSdkVersion.apiLevel = 22 versionCode = 1 //Integer type incremented by 1 for every release, major or minor, to Google store versionName = "1.0" //Real fully qualified major and minor release description buildConfigFields.with { //Defines fields in the generated Java BuildConfig class, in this case, for create() { //default config, that can be accessed by Java code type = "int" //eg "if (1 == BuildConfig.VALUE) { /*do something*/}". name = "VALUE" //See: [app or lib]/build/generated/source/buildConfig/[package path]/ value = "1" // BuildConfig.java } } } } android.buildTypes { release { minifyEnabled = false proguardFiles.add(file('proguard-rules.pro')) } } android.productFlavors { } android.sources { main{ jni { source { srcDirs = ['src/main/nop'] } } } main{ jniLibs { source { srcDirs = ['src/main/libs'] } } } } } dependencies { compile project(':aRBaseLib') } 
+8
source

Retrieving files from Github fixed it for me. I followed a short read of what they had to associate files with where you saved the SDK and reopened from this directory. I could not get this answer to work for me. Maybe something has changed since I had all .so libs; otherwise I did it wrong.

0
source

Source: https://habr.com/ru/post/1258691/


All Articles