简体   繁体   中英

why aar importing not happy in android studio?

not duplicate of another question because the .gradle files was already configured as suggested.(Note, it's not that I can't build the project but the IDE fail to identify the importing)


Newbie to android development

I am using the latest android studio (v3.1.3)

I have download source from a site and try to run that on an android device, which is successful, ie, I could build the apk but in android studio IDE, the import class shows error, the class seems imported from an aar file.

How to make the importing work(not showing error) in IDE?

在此处输入图片说明

And here is the build.gradle in app:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.0"
    defaultConfig {
        applicationId "com.tencent.tmgp.yybtestsdk"
        minSdkVersion 14
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile(name: 'YSDK_Android_1.3.9_917', ext: 'aar')
}

here is the build.gradle in project

   // 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.1.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        flatDir {
            dirs 'libs'
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Update your gradle.build (in the PROJECT level, not app level) like so.

        flatDir {
            dirs 'libs'
            dirs 'libs/app'
            dirs "../app/libs"
        }

Try changing

compile(name: 'YSDK_Android_1.3.9_917', ext: 'aar')

to

implementation(name: 'YSDK_Android_1.3.9_917', ext: 'aar')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM