I have a project that need to use protobuf (Getting the objects from server and parsing them).
For that I configured the following things:
Project level gradle.build
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.7.0'
classpath 'com.google.protobuf:protobuf-java:2.6.1'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App level gradle.build
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.protobuf'
android {
...
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:2.6.1'
}
}
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'
compile 'com.google.protobuf:protobuf-java:2.6.1'
compile 'com.google.protobuf:protobuf-gradle-plugin:0.7.0'
}
I put my proto file under .../app/src/main/proto/FILE.proto.
Once i am trying to build the project I am getting the following error:
Error:Execution failed for task ':app:generateDebugProto'.
> protoc: stdout: . stderr: /Users/XX/YY/app/build/extracted-protos/main: warning: directory does not exist.
/Users/XX/YY/app/build/extracted-include-protos/main: warning: directory does not exist.
...
protoc-gen-javanano: program not found or is not executable
--javanano_out: protoc-gen-javanano: Plugin failed with status code 1.
Any idea why is that? It should use the protoc from the repo and is should support that nano compilation.
Thanks.
Finally i downloaded the source from GitHub and compiled it. It fixed the issue because it includes the missing binary.
Related
I'm running tests on android using gradle and we're migrating our framework to junit5 to take advantage of some of it's tagging and filtering capabilities. I've created the dependencies in my build.gradle files and I'm able to get it to build and run using the gutter icon in android studio, but I'm unable to run my tests from the command line. I get the following error.
* What went wrong:
Execution failed for task ':app:compileTestKotlin'.
> Could not resolve all files for configuration ':app:testCompileClasspath'.
> Could not find junit:junit:5.7.0.
Searched in the following locations:
- https://jcenter.bintray.com/junit/junit/5.7.0/junit-5.7.0.pom
- https://jcenter.bintray.com/junit/junit/5.7.0/junit-5.7.0.jar
- https://repo.maven.apache.org/maven2/junit/junit/5.7.0/junit-5.7.0.pom
- https://repo.maven.apache.org/maven2/junit/junit/5.7.0/junit-5.7.0.jar
Required by:
project :app
Here's my build.gradle at the app level
plugins {
id 'io.qameta.allure' version '2.8.1' // Latest Plugin Version
id 'java'
}
allure {
autoconfigure = true
version = '2.13.7' // Latest Allure Version
useJUnit5 {
version = '2.13.7' // Latest Allure Version
}
}
sourceCompatibility = 1.8
repositories {
jcenter()
mavenCentral()
}
dependencies {
testImplementation(
'org.junit.jupiter:junit-jupiter-params:5.7.0',
'org.junit.jupiter:junit-jupiter-api:5.7.0'
)
testRuntimeOnly(
'org.junit.jupiter:junit-jupiter-engine:5.7.0'
)
}
test {
useJUnitPlatform(){
includeEngines 'junit-jupiter'
}
}
apply plugin: 'kotlin'
test {
systemProperty 'platform', project.findProperty('platform')
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.1'
implementation "io.appium:java-client:7.2.0"
// implementation 'junit:junit:4.12'
implementation 'junit:junit:5.7.0'
}
and here's the build.gradle at the project level.
buildscript {
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The error message says it. implementation 'junit:junit:5.7.0' is a non-existing dependency. Leave it away and it might already work.
I'm trying to use Push Notifications with Firebase Cloud Messaging and Cordova FCM. My google-services.json located in root folder with config.xml and same file in platforms/android/ folder. With ionic cordova build I got error:
A problem occurred configuring root project 'android'.
Cannot add task ':processDebugGoogleServices' as a task with that name already exists.
I've installs:
cordova plugin add cordova-support-google-services --save
ionic cordova plugin add cordova-plugin-fcm
npm install --save #ionic-native/fcm
and previously by another reason:
cordova plugin add cordova-plugin-googleplus ...
Now what I got:
platforms/android/cordova-plugin-fcm/myapp-FCMPlugin.gradle:
buildscript {
repositories {
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:3.0.0'
}
}
// apply plugin: 'com.google.gms.google-services'
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
platforms/android/cordova-support-google-services/myapp-build.gradle:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:3.2.0'
}
}
// apply plugin: 'com.google.gms.google-services'
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file
ext.postBuildExtras = {
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
}
platforms/android/project.properties:
target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.google.android.gms:play-services-auth:11.0.1
cordova.system.library.2=com.google.android.gms:play-services-identity:11.0.1
cordova.system.library.3=com.facebook.android:facebook-android-sdk:4.14.+
cordova.system.library.4=com.google.firebase:firebase-core:+
cordova.system.library.5=com.google.firebase:firebase-messaging:11.0.1
cordova.gradle.include.1=cordova-plugin-fcm/myapp-FCMPlugin.gradle
cordova.gradle.include.2=cordova-support-google-services/myapp-build.gradle
which is edited from:
target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.google.android.gms:play-services-auth:+
cordova.system.library.2=com.google.android.gms:play-services-identity:+
cordova.system.library.3=com.facebook.android:facebook-android-sdk:4.14.+
cordova.system.library.4=com.google.firebase:firebase-core:+
cordova.system.library.5=com.google.firebase:firebase-messaging:+
cordova.gradle.include.1=cordova-plugin-fcm/myapp-FCMPlugin.gradle
platforms/android/build.gradle which is also edited as project.properties:
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
debugCompile(project(path: "CordovaLib", configuration: "debug"))
releaseCompile(project(path: "CordovaLib", configuration: "release"))
compile "com.google.android.gms:play-services-auth:11.0.1"
compile "com.google.android.gms:play-services-identity:11.0.1"
compile "com.facebook.android:facebook-android-sdk:4.14.+"
compile "com.google.firebase:firebase-core:+"
compile "com.google.firebase:firebase-messaging:11.0.1"
// SUB-PROJECT DEPENDENCIES END
}
plugins/cordova-plugin-fcm/scr/android/FCMPlugin.gradle:
buildscript {
repositories {
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:3.0.0'
}
}
// apply plugin: 'com.google.gms.google-services'
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
plugins/cordova-support-google-services/build.gradle:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:3.2.0'
}
}
// apply plugin: 'com.google.gms.google-services'
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file
ext.postBuildExtras = {
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
}
Not sure what is wrong, advice would be helpful
The problem is you have conflicting versions of the GoogleServices plugin specified in your Gradle config:
/plugins/cordova-plugin-fcm/scr/android/FCMPlugin.gradle
com.google.gms:google-services:3.0.0
plugins/cordova-support-google-services/build.gradle
com.google.gms:google-services:3.2.0
You need to resolve this so the versions match.
I use Android Annotations in some other projects too. But in this it won't generate my files.
I try to migrate from Eclipse to Android Studio.
I'm also updating my libraries.
In Eclipse everything was working fine.
Note: Resolve log file to C:\Users\Raphael\Documents\!!!PROG\Eclipse\ARBEIT\FlohmoAndroid\flohmoLI\build\generated\source\apt\androidannotations.log
Note: Initialize AndroidAnnotations 3.3.2 with options {androidManifestFile=C:\Users\Raphael\Documents\!!!PROG\Eclipse\ARBEIT\FlohmoAndroid\flohmoLI\build\intermediates\manifests\full\debug\AndroidManifest.xml, resourcePackageName=at.flohmo}
C:\Users\Raphael\Documents\!!!PROG\Eclipse\ARBEIT\FlohmoAndroid\flohmoLI\src\main\java\at\flohmo\push\PushIntentReceiver.java:14: error: cannot find symbol
import at.flohmo.AdvertDetailsActivity_;
^
symbol: class AdvertDetailsActivity_
location: package at.flohmo
C:\Users\Raphael\Documents\!!!PROG\Eclipse\ARBEIT\FlohmoAndroid\flohmoLI\src\main\java\at\flohmo\push\PushIntentReceiver.java:15: error: cannot find symbol
import at.flohmo.AngeboteActivity_;
^
symbol: class AngeboteActivity_
location: package at.flohmo
C:\Users\Raphael\Documents\!!!PROG\Eclipse\ARBEIT\FlohmoAndroid\flohmoLI\src\main\java\at\flohmo\push\PushIntentReceiver.java:16: error: cannot find symbol
import at.flohmo.ChatActivity_;
^
symbol: class ChatActivity_
location: package at.flohmo
C:\Users\Raphael\Documents\!!!PROG\Eclipse\ARBEIT\FlohmoAndroid\flohmoLI\src\main\java\at\flohmo\push\PushIntentReceiver.java:17: error: cannot find symbol
import at.flohmo.MainActivity_;
^
symbol: class MainActivity_
location: package at.flohmo
warning: The following options were not recognized by any processor: '[androidManifestFile, resourcePackageName]'
4 errors
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':flohmoLI:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
here the gradle files:
project gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.google.gms:google-services:1.3.0-beta1'
}
}
allprojects {
repositories {
maven { url "http://dl.bintray.com/urbanairship/android" }
maven { url "http://dl.bintray.com/populov/maven" }
jcenter()
mavenCentral()
}
}
app gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'android-apt'
buildscript {
repositories {
mavenCentral()
}
dependencies {
// Since Android's Gradle plugin 0.11, you have to use android-apt >= 1.3
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.+'
}
}
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
resourcePackageName 'at.flohmo'
}
}
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "at.flohmo"
minSdkVersion 10
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
def AAVersion = '3.3.2'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
compile 'com.android.support:support-v4:22.0.0'
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.code.gson:gson:2.3'
compile 'com.google.android.gms:play-services:7.8.0'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.nhaarman.listviewanimations:lib-core:3.1.0#aar'
compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0#aar'
compile 'com.nhaarman.listviewanimations:lib-core-slh:3.1.0#aar'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.urbanairship.android:urbanairship-sdk:6.1.+'
compile 'com.viewpagerindicator:library:2.4.1#aar'
compile project(':flohmosimplecropimagelib')
compile project(':flohmoLibrarySlidingMenu')
compile project(':flohmoPullToRefreshLibrary')
compile files('libs/ADTECHMobileSDK.jar')
}
off-question: are there gradle projects for the last four compile requests?
I had the same problem I switched from repositories to be wrapped in allprojects block. That made it work.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
mavenLocal()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I'll try to remove specific section apt... See my last question, may you find something useful.
I'm answer without computer in front ;)
My objective is to compile a library that depends on other libraries (from HoloEverywhere), which are present in a remote maven repository, using Gradle and Android Studio (0.4.4).
If I set apply plugin: to android in the library's build.gradle, the remote maven dependencies are found, otherwise they are not (apply plugin: 'android-library').
Here is my build.gradle with the android object omitted to save in space:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
apply plugin: 'android-library'
repositories {
mavenCentral()
maven {url 'http://192.241.191.41/repo'}
}
android {...}
dependencies {
compile 'org.holoeverywhere:library:2.1.0#aar'
compile 'org.holoeverywhere:addon-preferences:2.1.0#aar'
compile fileTree(dir: 'libs', include: '*.jar')
}
The error I get when I press "Sync Project with Gradle Files" in Android Studio is:
7:30:48 PM Failed to refresh Gradle project 'MyTopProject'
Could not find org.holoeverywhere:library:2.1.0.
Required by:
MyTopProject:MyActualApp:unspecified > MyTopProject:MyMessedUpLib:unspecified
Search in build.gradle files
What am I doing wrong? Is this behaviour expected? Should I do it in another way?
Thank you very much.
I am using gradle in Android studio for an android project. I have a jar that I downloaded called TestFlightAppLib.jar. This jar isn't present in the maven repository so I can't just put it in my build.gradle.
How can I add this JAR file to my project? I don't see any option to add an external jar to the project.
Update
This is my complete build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "18.1.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 18
}
}
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:18.0.+'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.squareup.retrofit:retrofit:1.2.2'
compile 'com.github.rtyley:roboguice-sherlock:1.5'
compile 'org.roboguice:roboguice:2.0'
compile files('libs/TestFlightLib.jar')
}
This is the error message:
Gradle: Execution failed for task ':MyProject:compileDebug'.
> Compilation failed; see the compiler error output for details.
/Users/droid/android/MyProjectProject/MyProject/src/main/java/com/mypkg/ui/activity/MainApplication.java
Gradle: error: package com.testflightapp.lib does not exist
Here is the class:
import com.testflightapp.lib.TestFlight;
public class MainApplication {
}
just add
compile fileTree(dir: 'libs', include: '*.jar')
to your dependencies in the build.gradle then all the jars in the libs folder will be included.
Put the jar in a folder called libs (created on the root of your project). Once moved right click on the jar and you will find "add as library". Click on it and select the module!