我终于将我的eclipse android项目迁移到Android Studio。我创建了一个包含两个模块的项目。一个模块是一个图书馆项目。另一个是简单的活动项目,其中包括图书馆模块。Android Studio库项目引用未解决的符号
Project/
app/ (Activity Project)
br_lib/ (Library Project)
在应用程序的“模块设置”中,我将一个dependency添加到lib模块中。 的LIB模块项目通常会生成,但我的应用程序模块构建失败每次我让到lib模块类的一个参考:
import org.apache.http.client.HttpClient;
import org.cddevlib.breathe.setup.Utils <-- // lib refrence;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Utils.convertName(""); // <--- lib module static class;
}
}
错误:
Error:(9, 34) error: cannot find symbol class Utils
Error:(25, 9) error: cannot find symbol variable Utils
有什么不对?我错过了什么?谢谢
这是应用模块gradle这个:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "pro.breathe.cddev.org.br_gold"
minSdkVersion 22
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile project(':br_lib')
compile fileTree(dir: 'libs', include: ['*.jar'])
}
这是LIB模块gradle这个:
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 9
}
dependencies {
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:cardview-v7:22.2.1'
compile 'com.android.support:gridlayout-v7:22.2.1'
compile 'com.android.support:recyclerview-v7:22.2.1'
compile 'com.google.android.gms:play-services:7.8.0'
}
buildTypes {
release {
minifyEnabled true
proguardFiles 'proguard.cfg'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
这是项目的摇篮:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
设置gradle这个是:
include ':app', ':br_lib'
编译文件位置不正确 –
发布您的settings.gradle并且不要使用您的jar文件的绝对路径。 此外,您正在使用不同版本的支持库。 –
是的,我认为这是您的位置错误。我是对的先生加布里埃尔 –