我还没有找到正确的答案。这是我与Android Studio的第一个项目,我几乎失去了耐心:)。 Theme.AppCompat.Light.DarkActionBar标记为红色。Android Studio无法解析符号Theme.AppCompat.Light.DarkActionBar /无法解析“R”
这是我的styles.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
这是我的build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "helloworld.spsa3.helloworldproject"
minSdkVersion 10
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
}
最后,这是我的第二个问题,我敢肯定,他们是相关的。 “R”也无法解决。 “R”也用红色标出。
因此,这里是我的MainActivityFragment()类:
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class MainActivityFragment extends Fragment{
public MainActivityFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_main, container, false);
}
}
任何想法?
这意味着在你的布局文件或可绘制一些编译问题。基本上res文件夹中的任何东西都可能导致R无法编译 –
尝试构建 - >清理项目 –
@kapsym所以你有一个想法如何解决这个问题..你有过同样的问题吗? – Sarina