找不到 AppCompatActivity。什么都没用
AppCompatActivity not found. Nothing worked
我花了 3 天,每天 8 小时,尽一切努力使这些东西工作,但没有任何成功。
我不断收到 "AppCompatActivity not found"。我不知道为什么。有什么想法吗?
这是代码:
public abstract class DroidActivity extends AppCompatActivity
那是 gradle 文件:
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'
}
你应该使用
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
。希望对您有所帮助。
compile 'com.android.support:appcompat-v7:23.1.1'
你必须使用等级 - "compile 'com.android.support:appcompat-v7:22.2.1'" 或者新的最新版本并且导入文件是 --import android.support.v7.app.AppCompatActivity;然后你会得到AppCompatActivity。它在这里工作正常..
实际上一切正常。
问题是这样的。我只添加了
import android.support.v7.app.AppCompatActivity
一开始(我想用 alt+enter 自动完成,但这是不可能的)并修复了每个模块的每个 compileSdkVersion 从 22 到 23。现在可以正常使用了。
我找到了解决办法!用空白Activity创建一个新项目,比较错误的gradle和新项目的gradle,将错误的更改为这两行中的新的,例如:
compileSdkVersion 27
implementation 'com.android.support:appcompat-v7:27.1.1'
AppCompat版本好像要设置成本地的compileSdkVersion!
我花了 3 天,每天 8 小时,尽一切努力使这些东西工作,但没有任何成功。
我不断收到 "AppCompatActivity not found"。我不知道为什么。有什么想法吗?
这是代码:
public abstract class DroidActivity extends AppCompatActivity
那是 gradle 文件:
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'
}
你应该使用
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
。希望对您有所帮助。
compile 'com.android.support:appcompat-v7:23.1.1'
你必须使用等级 - "compile 'com.android.support:appcompat-v7:22.2.1'" 或者新的最新版本并且导入文件是 --import android.support.v7.app.AppCompatActivity;然后你会得到AppCompatActivity。它在这里工作正常..
实际上一切正常。
问题是这样的。我只添加了
import android.support.v7.app.AppCompatActivity
一开始(我想用 alt+enter 自动完成,但这是不可能的)并修复了每个模块的每个 compileSdkVersion 从 22 到 23。现在可以正常使用了。
我找到了解决办法!用空白Activity创建一个新项目,比较错误的gradle和新项目的gradle,将错误的更改为这两行中的新的,例如:
compileSdkVersion 27
implementation 'com.android.support:appcompat-v7:27.1.1'
AppCompat版本好像要设置成本地的compileSdkVersion!