I have setup ActiveAndroid as per the wiki instructions using latest version of AndroidStudio. I am using product Flavours. This is my gradle build file:
apply plugin: 'android'
apply plugin: 'android-apt'
apt {
arguments {
androidManifestFile variant.processResources.manifestFile
resourcePackageName android.defaultConfig.packageName
}
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
a {
packageName "com.a.a"
}
b {
packageName "com.a.b" …Run Code Online (Sandbox Code Playgroud) 当RoboGuice触发Event时,我的事件回调将在哪里执行,在哪个线程?例如,我有一个活动(@Observes OnUpdateUiEvent e).我还有一个后台线程,它会触发新的OnUpdateUiEvent("data").那么,我的do()方法将在我理解的bg线程中执行?如果我使用AndroidAnnotations中的@Background注释do(),会是什么?预处理器是否应该在runInUiThread()中调用do()?
如果一切正常,我认为这种模式将提供线程之间最简单的通信方式.
我尝试使用Maven和androidannotations来构建我的apk,但独立于任何IDE(我实际上使用IntelliJ IDEA而不是Eclipse,但我希望它完全独立于IDE,因此它也可以在任何IDE上完美运行构建服务器).
注释似乎得到了正确处理,但它们没有被编译到apk中,这是我目前所处的位置.
我尝试使用中的<includes>部分maven-compiler-plugin,并且路径应该是正确的 - 它存在并且还包含已处理,生成的注释,java类,这是Android主要活动但带有下划线(_)后缀.
有一个wiki页面描述如何使用Maven + Eclipse,但是它太多绑定到Eclipse IDE了.https://github.com/excilys/androidannotations/wiki/Building-Project-Maven-Eclipse 所以它无法帮助我解决问题.
这是我的pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>de-mycompany-myproject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>com-mycompany-base-myproject</name>
<prerequisites>
<maven>2.2.1</maven>
</prerequisites>
<properties>
<platform.version>2.3.3</platform.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${platform.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.googlecode.androidannotations</groupId>
<artifactId>androidannotations</artifactId>
<version>2.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.googlecode.androidannotations</groupId>
<artifactId>androidannotations</artifactId>
<classifier>api</classifier>
<version>2.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
<sdk>
<platform>10</platform> …Run Code Online (Sandbox Code Playgroud) android annotations maven annotation-processing android-annotations
我在我的项目中使用Android Annotation并尝试POST通过以下代码发送请求,但是在下面的代码中出现了问题,因为我没有按预期得到响应:
@Rest(rootUrl = "http://xyz.com", converters = {GsonHttpMessageConverter.class})
public interface A {
@Post("/authenticate/email/")
public Object attemptLogin(Map data);
}
Run Code Online (Sandbox Code Playgroud)
哪里data是(key, value)对.我有什么遗漏也许我必须设置request-header或data不应该是JSON吗?
我正在使用Android Annotations Framework,专门用于Rest Integration.我有以下代码.
主机配置的接口
public interface Host {
public String URL = "http://192.168.2.137";
}
Run Code Online (Sandbox Code Playgroud)
以及用于休息通信的带注释的接口.
@Rest(rootUrl = Host.URL, converters = { MappingJacksonHttpMessageConverter.class })
public interface RestClient {
@Get("/entities.json")
Entity[] allEntities();
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,为什么注释属性Rest.rootUrl的值必须是常量表达式?以及如何为Rest.rootUrl使用String资源?
我想做点什么
@EBean
public class Host{
@StringRes
String URL;
}
Run Code Online (Sandbox Code Playgroud)
但是使用RestClient接口是不可能的.
我们的想法是处理本地化的休息应用程序,假设语言不同的URL
http://en.myapp.com
http://es.myapp.com
Run Code Online (Sandbox Code Playgroud)
我知道Java接口必须具有最终属性,但是,有一种方法可以处理本地化的rootUrl值吗?
谢谢.
我正在向服务器发送一个多部分请求,该服务器将包含一个图像,以及一些字符串.我还没有找到任何关于如何完成这项工作的指南,我发现的只是如何发布和获取和放置等等,但没有任何关于多部分.我很乐意提供任何帮助,谢谢
我已成功使用androidannotations @Extra来解码一个intent并获取发送的消息,因为这个片段演示了:
@Extra(MyActivity.MESSAGE)
String intentMessage;
@ViewById(displayMessage)
TextView textView;
@AfterViews
protected void init() {
textView.setText(intentMessage);
}
Run Code Online (Sandbox Code Playgroud)
我想知道如果可能的话,首先使用注释创建意图.例如,更换以下内容
Intent intent = new Intent(this,DisplayMessageActivity_.class);
intent.putExtra(MESSAGE, s);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
有点东西.这可能吗?(我对这一切都很陌生,所以可能错过了一些非常明显的东西)
解:
DisplayMessageActivity_.intent(this).intentMessage(s).start();
Run Code Online (Sandbox Code Playgroud)
其中,intentMessage是额外字段的名称.
我正在使用带有gradle插件1.0.1的Android Studio 1.1 beta 4,并尝试在正式版本之后将Android Annotations添加到我的项目中.所以我得到以下build.gradle文件:
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "ru.itloft.moneytracker"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
}
}
def AAVersion = '3.2'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
apt "org.androidannotations:androidannotations:$AAVersion"
compile …Run Code Online (Sandbox Code Playgroud) 有人知道如何使用插件编译器使用Android Annotations吗?
在这里我的app/build.gradle和这里我的项目build.gradle
使用此配置,我在构建项目时出现此错误消息:
Error:Could not get unknown property 'classpath' for task ':app:transformJackWithJackForDebug' of type com.android.build.gradle.internal.pipeline.TransformTask.
Run Code Online (Sandbox Code Playgroud) android gradle annotation-processing jack android-annotations