androidandroid-studiowebrtcbuild.gradleandroid-5.1.1-lollipop

webrtc native API 'vectorDrawable' & 'Task' error when sync build.grandle


First at all: I copy and paste these question from my 'off topic' post into android enthusiast. Someone suggest me to ask here for these.

I try to install on my lollipop device AppRTCMobile example containing on official repo.

i find a first little error on grandle.build file (not closing "}").Actually I obtain these error on my log file:

WARN - ect.sync.idea.ProjectSetUpTask - Could not get unknown property     

    'vectorDrawables' for source set default config of type com.android.build.gradle.internal.api.DefaultAndroidSourceSet.

Consult IDE log for more details (Help | Show Log) 
2018-02-13 13:07:01,478 [d thread 6]   INFO - e.project.sync.GradleSyncState - Gradle sync failed: Could not get unknown  property 'vectorDrawables' for source set default config of type com.android.build.gradle.internal.api.DefaultAndroidSourceSet.

my build.grandle result these:

// Generated by //build/android/generate_gradle.py

buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com'
        }
    }
    dependencies {
        classpath "com.android.tools.build:gradle:3.1.0-alpha08"
    } }

and my example AppRTCMobile build.grandle result these:

// Generated by //build/android/generate_gradle.py

apply plugin: "com.android.application"

android {
    compileSdkVersion "android-27"
    buildToolsVersion "27.0.1"

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

sourceSets {
    main {
        aidl.srcDirs = []
        assets.srcDirs = []
        java.srcDirs = []
        jni.srcDirs = []
        renderscript.srcDirs = []
        res.srcDirs = []
        resources.srcDirs = []
    }
    test {
        aidl.srcDirs = []
        assets.srcDirs = []
        java.srcDirs = []
        jni.srcDirs = []
        renderscript.srcDirs = []
        res.srcDirs = []
        resources.srcDirs = []
    }
    androidTest {
        aidl.srcDirs = []
        assets.srcDirs = []
        java.srcDirs = []
        jni.srcDirs = []
        renderscript.srcDirs = []
        res.srcDirs = []
        resources.srcDirs = []
    }
    debug {
        aidl.srcDirs = []
        assets.srcDirs = []
        java.srcDirs = []
        jni.srcDirs = []
        renderscript.srcDirs = []
        res.srcDirs = []
        resources.srcDirs = []
    }
    release {
        aidl.srcDirs = []
        assets.srcDirs = []
        java.srcDirs = []
        jni.srcDirs = []
        renderscript.srcDirs = []
        res.srcDirs = []
        resources.srcDirs = []
    }

    main {
        manifest.srcFile "../../../../../examples/androidapp/AndroidManifest.xml"
        java.srcDirs = [
            "extracted-srcjars",
        ]
        java.filter.exclude(
        )
        jniLibs.srcDirs = [
            "symlinked-libs",
        ]
        res.srcDirs = [
            "extracted-res",
        ]
    }




    defaultConfig {
        vectorDrawables.useSupportLibrary = true
    } }


dependencies {
    implementation project(path: ":examples.AppRTCMobile_javalib")
    implementation project(path: ":rtc_base.base_java")
    implementation project(path: ":base.base_java")



} afterEvaluate {
    def tasksToDisable = tasks.findAll {
        return (it.name.equals('generateDebugSources')  // causes unwanted AndroidManifest.java
                || it.name.equals('generateReleaseSources')
                || it.name.endsWith('BuildConfig')  // causes unwanted BuildConfig.java
                || it.name.equals('preDebugAndroidTestBuild')
                || it.name.endsWith('Aidl')
                || it.name.endsWith('Renderscript')
                || it.name.endsWith('Shaders'))
    }
    tasksToDisable.each { Task task ->
      task.enabled = false
    } }

Why I got these error? My buld.grandle on AppRTCMobile is wrong or contain some error??

UPDATE:

I try to clear project and import only AppRTCMobile example .... multiple error only about vectorDrawable: choice 1) comment out "vectorDrawables.useSupportLibrary = true" line in every build file of project. Choice 2) utilize the right library (more than 23.x) and set min support sdk api to 21 instead 16.

I use chose 1). result these error:

/home/myoffice/chromium/src/out/DebugArm/gradle/examples/AppRTCMobile/build/generated/source/r/debug/org/appspot/apprtc/R.java
Error:(10, 14) error: duplicate class: org.appspot.apprtc.R

obviusly refactor that class not work. These error type where came from?

regards bkt


Solution

  • grandle scripts file SECTION: grandle-wrapper.properties file change to:

    #Thu Nov 16 19:42:05 CST 2017
    distributionBase=GRADLE_USER_HOME
    distributionPath=wrapper/dists
    zipStoreBase=GRADLE_USER_HOME
    zipStorePath=wrapper/dists
    distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
    

    build.grandle(project.....) file:

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
    
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.0.1'
    
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            google()
            jcenter()
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    

    build.grandle(app) file:

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 26
        defaultConfig {
            applicationId "org.appspot.apprtc"
            minSdkVersion 18
            targetSdkVersion 22
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    
        sourceSets.main {
            jniLibs.srcDir 'libs'
            jni.srcDirs = [] //disable automatic ndk-build call
        }
    
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    }
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support.constraint:constraint-layout:1.0.2'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.1'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    }
    

    after these the error disappear .... but is not tested on my device lollipop, since I'm not a genius in java, I've gone fork another project and checked why that worked while webrtc official no. So on my lollipop now run the fork project + all my changes and I no longer tried webrtc official example that otherwise was too rich in useless things for my application. After these Android Studio now accept to sync and run the webrtc wxample official.

    p.s. real sorry for my late reply ... but I was out of office until friday.

    regards bkt