我還沒有找到正確的答案。這是我與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