I want to use realm database in my app for that i add this lines to my build.gradle file in app
apply plugin: 'realm-android'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "io.realm:realm-gradle-plugin:1.1.0"
}
}
and this is my table code:
public class Country extends RealmObject {
#Ignore
public static String NAME="name";
#Ignore
public static String POPULATION="population";
#PrimaryKey
private String name;
private int population;
public Country() { }
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getPopulation() {
return population;
}
public void setPopulation(int population) {
this.population = population;
}
}
but when I use this code and nothing else "I mean never use country table" I getting this error when run my app:
An exception has occurred in the compiler (1.8.0_05). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
com.sun.tools.javac.code.Symbol$CompletionFailure: class file for rx.Observable not found
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
my app.gradle file
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.sss.ddd"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
repositories {
maven { url "https://jitpack.io" }
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
}
and this is my project.gradle file
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath "io.realm:realm-gradle-plugin:1.1.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
can anyone help me abou this?
thanks.
Thanks all For your attentions but I found my solution.
I add this lines to my project Gradle file:
allprojects {
repositories {
jcenter()
maven {
url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo'
}
}
}
and this to my app gradle file
compile 'com.uphyca:stetho_realm:0.9.0'
compile 'io.reactivex:rxjava:1.1.0'
compile 'com.facebook.stetho:stetho:1.3.1'
I don't know why I should add this lines and realm documentation never refer to this but know my project works fine.
I know this is wired behavior but its work.
please share me if you know a better answer.
Updating JDK to version 1.8.3 solved the issue.
JDK can be downloaded from
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Setting up JDK on android can be done using
How to set Java SDK path in AndroidStudio?
This is how I solved the problem:
1.) Create a new package and name it rx
2.) Inside this package add a class named Observable, empty class.
It compiles fine now.
Related
I am developing an app in Unity and need to copy some files before the build.
I have looked around for how to do this and this is what I created (I removed all the "noise"):
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
}
}
allprojects {
repositories {
flatDir {
dirs 'libs'
}
}
}
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
android {
compileSdkVersion 25
.....
buildTypes {
.......
}
preBuild.dependsOn copyRes
}
task copyRes(type: Copy) {
from file("'../../Assets/Plugins/Android/res")
into file("./src/main/res/values")
}
My build is failing with the following error:
Could not get unknown property 'copyRes' for object of type com.android.build.gradle.AppExtension
This is just an ordering issue. You have tried to use copyRes before it exists.
Option 1 - Use a string instead of the variable
preBuild.dependsOn 'copyRes'
Option 2 - Declare the copyRes task first, before the android {...} block
I am coming because I can't make work my communication between my API (Go) and my client (Android).
I have this protobuf file:
syntax = "proto3";
option java_package = "com.emixam23.rushpoc.protobuf";
option java_outer_classname = "HelloWorld";
package helloworld;
// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply) {}
}
// The request message containing the user's name.
message HelloRequest {
string name = 1;
}
// The response message containing the greetings
message HelloReply {
string message = 1;
}
The protobuf file comes from the example of https://grpc.io/docs/quickstart/go.html, I just didn't implemented the SayHelloAgain. What i am trying to achieve is, from my android app, SayHello to my Go API and get a reply...
For android, I followed that tutorial (https://grpc.io/docs/quickstart/android.html) in order to, from the protobuf file, to communicate with my API. However, there is a stub, comming from I don't know where.
So I searched about how to create a stub (https://grpc.io/docs/tutorials/basic/android.html) and nothing.. ManagedChannelBuilder doesn't exist and I can't find the way to install it..
PS: to generate my Java class from the protobuf file, I followed that tutorial: https://proandroiddev.com/how-to-setup-your-android-app-to-use-protobuf-96132340de5c
Am I in the right direction or totally wrong?
My project structure:
APP build.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.protobuf'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.rushpoc.emixam23.androidapp"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
//Protobuf
implementation 'com.google.protobuf:protobuf-lite:3.0.0'
implementation 'io.grpc:grpc-okhttp:1.13.2'
implementation 'io.grpc:grpc-protobuf-lite:1.13.2'
implementation 'io.grpc:grpc-stub:1.13.2'
}
protobuf {
generatedFilesBaseDir = "$projectDir/generated"
protoc {
// You still need protoc like in the non-Android case
artifact = 'com.google.protobuf:protoc:3.0.0'
}
plugins {
javalite {
// The codegen for lite comes as a separate artifact
artifact = 'com.google.protobuf:protoc-gen-javalite:3.0.0'
}
grpc {
artifact = 'io.grpc:protoc-gen-grpc-java:1.13.2'
}
}
generateProtoTasks {
all().each { task ->
task.builtins {
java
}
task.plugins {
grpc {}
}
}
}
}
TOP-LEVEL/Root build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.protobufVersion = '0.8.6'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath "com.google.protobuf:protobuf-gradle-plugin:$protobufVersion"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I haven't checked the entire gradle files yet but I see in your screenshot the .proto file was in src/main/protobufs, which was not following either of the tutorials you mentioned. The protobuf gradle plugin does not detect this directory by default. Therefore I suggest you change it into the default directory src/main/proto. If you would like to insist putting the .proto file in src/main/protobufs, you might need let the protobuf gradle plugin know it by adding
// see https://github.com/google/protobuf-gradle-plugin#customizing-source-directories
sourceSets {
main {
proto {
// In addition to the default 'src/main/proto'
srcDir 'src/main/protobufs'
}
}
}
After that, the protobuf gradle plugin will generate the java code if there's no other mistake.
The problem exists when the code that uses the generated 'Dagger' prefixed on a component is not commented out. If it was commented out, the generated Dagger 2 files are generated.
BookModule
#Module
public class BookModule {
#Provides
public Book providesBook(){
return new Book();
}
}
BookComponent
#Component(modules = BookModule.class)
public interface BookComponent {
void inject(MainActivity activity);
public Book getBook();
}
MainApplication
public class MainApplication extends Application {
public static BookComponent mBookComponent;
#Override
public void onCreate() {
super.onCreate();
mBookComponent = DaggerBookComponent.builder().bookModule(new BookModule()).build();
}
}
Build.gradle(Application)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Build.gradle(Project)
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 24
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.bryan.myapplication"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
jackOptions{
enabled = true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:support-v4:24.2.0'
compile group: 'com.google.dagger', name: 'dagger', version: '2.10-rc1'
apt group: 'com.google.dagger', name: 'dagger-compiler', version: '2.10-rc1'
compile group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3'
}
Error Stacktrace
ERROR: C:\bin\AndroidProjects\MyApplication\app\src\main\java\com\example\lloyd\myapplication\MainApplication.java:12.26: DaggerBookComponent cannot be resolved
com.android.jack.api.v01.CompilationException: Failed to compile
at com.android.jack.api.v01.impl.Api01ConfigImpl$Api01CompilationTaskImpl.run(Api01ConfigImpl.java:144)
at com.android.builder.core.AndroidBuilder.convertByteCodeUsingJackApis(AndroidBuilder.java:1931)
at com.android.build.gradle.tasks.JackTask.doMinification(JackTask.java:148)
at com.android.build.gradle.tasks.JackTask.access$000(JackTask.java:73)
at com.android.build.gradle.tasks.JackTask$1.run(JackTask.java:112)
at com.android.builder.tasks.Job.runTask(Job.java:51)
at com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41)
at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:223)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.android.jack.frontend.FrontendCompilationException: Failed to compile
at com.android.jack.Jack.buildSession(Jack.java:1053)
at com.android.jack.Jack.run(Jack.java:540)
at com.android.jack.api.v01.impl.Api01ConfigImpl$Api01CompilationTaskImpl.run(Api01ConfigImpl.java:124)
... 8 more
mBookComponent = DaggerBookComponent.builder().bookModule(new BookModule()).build();
The code from above is in the MainApplication and it is the problem, if I commented it out, it rebuilds completely fine. But when I left it as it is, it got an error saying the 'DaggerBookComponent' cannot be resolved, by this time the generated DaggerBookComponent is deleted which results in cannot be resolved
When you do a rebuild, the build system looks at the Dagger module and component classes and generates the actual classes that make all of dagger work. When you do a normal incremental build, it doesn't (it assumes the old versions are still good). This means when you rebuild if there's some error in your program or in your dagger components/modules it will not be able to rebuild these files.
So basically, you have a bug somewhere, likely (although not necessarily) in your dagger setup. When you fix it, you'll stop having problems.
i am integrating "Strip" payment method in my app but when i add the stripe dependence compile 'com.stripe:stripe-android:1.0.3' also try compile 'com.stripe:stripe-android:+' an error occur that is
i see many answer for realm Re-linker like using
compile 'com.getkeepsafe.relinker:relinker:1.2.1'
Compile 'io.reactivex:rxjava:1.1.0' but the problem is still exist
this is my Realm application class
public class WifiExploreApplication extends Application {
#Override
public void onCreate(){
super.onCreate();
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder(this)
.name("com.holygon.zaingz.alu").build();
Realm.setDefaultConfiguration(realmConfiguration)
}
}
this is my gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 'Google Apis:Google Apis:23'
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.wifiexplorer"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
multiDexEnabled true
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:cardview-v7:23.2.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.github.sembozdemir:ViewPagerArrowIndicator:1.0.0'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.android.support:multidex:1.0.0'
compile "com.android.support:support-v4:23.0.0"
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.getkeepsafe.relinker:relinker:1.2.1'
compile 'com.stripe:stripe-android:1.0.3'
}
dependencies {
repositories {
mavenCentral()
}
compile 'com.sothree.slidinguppanel:library:3.3.0'
}
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
apply plugin: 'realm-android'
and
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath "io.realm:realm-gradle-plugin:0.88.2"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
before using stripe all the things going well but when i use strip it will show error
any suggestion will appreciate able..
You're using the AAR Gradle Plugin version of Realm (as in 0.88.0+, but an outdated one, considering the latest is 1.1.0) but you're never actually calling apply plugin: 'realm-android' in your build.gradle file.
You're also missing this from your application class
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
Oh by the way, you probably should use modularized version of Google Play Services so that you wouldn't even need Multi-Dex in the first place.
I am not able to add notifyPropertyChanged(int itemId) because of certain issue in gradle, i guess!
any help would be well appreciated
public class RegisterForm extends BaseObservable {
#Bindable
public String firstName;
#Bindable
public int getFirstNameLabelVisibility(){
return TextUtils.isEmpty(firstName) ? View.INVISIBLE : View.VISIBLE;
}
public void setFirstNameFromView(String firstNameFromView) {
firstName = firstNameFromView;
// notifyPropertyChanged(BR.firstName); this line is giving error!
}
}
Build.gradle // for App
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
apply plugin: 'android-apt'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.jivrajsingh.databindingimp"
minSdkVersion 15
targetSdkVersion 23
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
}
}
configurations {
apt
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
apt 'com.android.databinding:compiler:1.0-rc0'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.google.android.gms:play-services-auth:8.3.0'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
}
Build.gradle // for project
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
// classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.android.databinding:dataBinder:1.0-rc2'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.+'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Thanks for your precious time :)
You have the old plugin setup with the new gradle version.
Remove the data binding plugin & its dependency from classpath.
Now it is integrated and all you need is
android {
dataBinding { enabled = true }
}
http://developer.android.com/tools/data-binding/guide.html