gpt4 book ai didi

java - Android studio 中的 Android 注解 - 无法访问 Activity_?

转载 作者:行者123 更新时间:2023-12-01 18:19:49 24 4
gpt4 key购买 nike

如何使用 Android Studio 添加 Android 注解有多种解决方案。这次我只是通过 AS 接口(interface)添加它。它显示所有注释,例如 @EActivity 但它不访问生成的类 ActivityName_

enter image description here

编辑:

我还将“范围”更改为“已提供”,但没有任何结果。 带有 gradle 内容的选项:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.package">

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity android:name=".MainFragmentActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>


</application>

</manifest>

内部build.gradle:

buildscript {
repositories {
mavenCentral()
}
dependencies {
// replace with the current version of the Android plugin
classpath 'com.android.tools.build:gradle:1.0.0'
// replace with the current version of the android-apt plugin
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
repositories {
mavenCentral()
mavenLocal()
}
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
def AAVersion = '3.1'
dependencies {
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
}

//androidManifestFile variant.outputs[0].processResources.manifestFile
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
// androidManifestFile variant.outputs[1].processResources.manifestFile
// if you have multiple outputs (when using splits), you may want to have other index than 0

resourcePackageName 'com.package'

// If you're using Android NBS flavors you should use the following line instead of hard-coded packageName
// resourcePackageName android.defaultConfig.packageName

// You can set optional annotation processing options here, like these commented options:
// logLevel 'INFO'
// logFile '/var/log/aa.log'
}
}

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.1"

defaultConfig {
applicationId "com.package"
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile 'com.android.support:appcompat-v7:21.0.2'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'org.androidannotations:androidannotations:3.2'
provided 'org.androidannotations:androidannotations-api:3.2'
compile 'com.android.support:support-v4:21.0.2'
}

全局项目build.gradle:

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0-rc4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
}
}

最佳答案

面临同样的问题。我通过使用默认的 gradle 包装器解决了这个问题。

在 Android studio 设置 -> 构建、执行、部署 -> 构建工具 -> Gradle

希望这有帮助

关于java - Android studio 中的 Android 注解 - 无法访问 Activity_?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27930899/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com