在 Android Studio 中使用原理图库时生成源文件夹时出错



我在构建项目时收到以下消息。我想问题是由于使用此存储库 https://github.com/SimonVT/schematic 但我无法纠正它。

Warning:Folder /home/priyanshu/AndroidStudioProjects/Ud Courses/AdvancedAndroid_Squawker-TFCM.00-StartingCode/app/build/source/apt/debug
Information:3rd-party Gradle plug-ins may be the cause

同样在我的AndroidMenifest中.xml工作室无法识别android:name=".provider.generated.SquawkProvider"警告消息是这样的 -

Unresolved package 'generated' less  
Validates resource references inside Android XML files

这是我的AndroidMenifest.xml -

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.example.com.squawker">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="fcm.SquawkMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service
android:name=".fcm.SquawkFirebaseInstanceService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<provider
android:name=".provider.generated.SquawkProvider"
android:authorities="android.example.com.squawker.provider.provider"
android:exported="false" />
<activity
android:name=".following.FollowingPreferenceActivity"
android:parentActivityName=".MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
</application>
</manifest>

这是我的build.gradle文件(模块:app( -

apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "android.example.com.squawker"
minSdkVersion 16
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'
})
// RecyclerView
// Schematic dependencies for ContentProvider
// Preferences Dependencies
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.google.firebase:firebase-messaging:9.2.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'net.simonvt.schematic:schematic:0.6.3'
compile 'com.android.support:preference-v7:25.3.1'
testCompile 'junit:junit:4.12'
apt 'net.simonvt.schematic:schematic-compiler:0.6.3'
}
apply plugin: 'com.google.gms.google-services'

我设法找到了解决此问题的方法。

在 app/build.gradle 上使用示意图版本"0.7.0"。

apt 'net.simonvt.schematic:schematic-compiler:0.7.0'
annotationProcessor 'net.simonvt.schematic:schematic-compiler:0.7.0'
compile 'net.simonvt.schematic:schematic:0.7.0'

并在文件末尾添加:

sourceSets {
main.java.srcDirs += 'build/source/apt/{buildType}'
}

我在Android Studio 3.0和Gradle 4.1上对此进行了测试。


如果你在使用apt时遇到错误,你可能需要在你的app/build.gradle上添加:

apply plugin: 'android-apt'

在build.gradle上:

dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2'
}

最新更新