这是3天,每天8小时,我正在尽一切努力使这些东西工作但没有任何成功。
我一直在“找不到AppCompatActivity”。我不知道为什么。有什么想法吗?
这就是代码:
apply plugin: "com.android.library"
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile project(':gsd_droid_common:External:ErlangOTP')
compile project(':gsd_droid_common:External:datetimepicker')
compile 'de.greenrobot:eventbus:2.4.0'
}
这就是gradle文件:
If you want to replace multiple "-" from single string
var str = "only-for-test";
str.replace(/-/g, "");
//out put : onlyfortest
答案 0 :(得分:2)
你应该使用
compile 'com.android.support:appcompat-v7:23.1.1'
最后
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile project(':gsd_droid_common:External:ErlangOTP')
compile project(':gsd_droid_common:External:datetimepicker')
compile 'de.greenrobot:eventbus:2.4.0'
}
然后 Clean-Rebuild-Restart-Sync your Project
。希望它会有所帮助。
答案 1 :(得分:2)
compile 'com.android.support:appcompat-v7:23.1.1'
答案 2 :(得分:1)
你必须使用成绩 - &#34;编译&#39; com.android.support:appcompat-v7:22.2.1&#39;&#34;或者新的最新版本和导入文件是--import android.support.v7.app.AppCompatActivity;然后你将获得AppCompatActivity。它在这里工作正常..
答案 3 :(得分:1)
实际上一切都被罚款了。
问题是这样的。我只添加了
import android.support.v7.app.AppCompatActivity
一开始(我想用alt + enter自动完成但不可能)并将每个模块的每个compileSdkVersion修复为22到23。现在它工作得很好。
答案 4 :(得分:0)
我找到了解决方案!用空白的Activity创建一个新项目,比较错误的gradle和新项目的gradle,将错误的代码更改为这两行中的新代码,例如:
compileSdkVersion 27
implementation 'com.android.support:appcompat-v7:27.1.1'
AppCompat版本似乎必须设置为本地compileSdkVersion!