Android Studio 3.4.2
I has main project (app) that use module mytransport like this:
app/build.gradle
dependencies {
annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation('com.crashlytics.sdk.android:crashlytics:2.7.0@aar') { transitive = true; }
implementation 'com.google.android.material:material:1.1.0-alpha07'
implementation "org.androidannotations:androidannotations-api:$AAVersion"
implementation project(':mytransport')
}
In mytransport/build.gradle:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.google.code.gson:gson:2.8.5'
}
In mytransport
code I success use code like this:
in MyProjectmytransportsrcmainjavacommycompanyandroidmytransportutilMyUtil.java
snippet:
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
public class JSONUtil {
private static GsonBuilder gsonbuilder = new GsonBuilder();
Nice.
Now I want in main app to use gson lib.
So in main app I try this in
MyProjectandroidMyProjectappsrcmainjavacommycompanyandroidmyprojectmainMainApp.java
snippet
import android.app.Application;
import android.content.Context;
public class MainApp extends Application {
private static GsonBuilder gsonbuilder = new GsonBuilder();
but I get compile error:
Cannot resolve symbol 'GsonBuilder'
Why it can't find gson lib in main app? I use it TRANSITIVE by mytransport
module
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…