Non-programmer newbie here. I have issues integrating Flurry Analytics into my first Godot Android project (and will do it for iOS after too). I've done everything as instructed I believe but I keep getting errors when exporting to Android and this is the latest one I got;
> Task :compileDebugJavaWithJavac FAILED
C:\Users\Acer\Desktop\Godot\game\android\build\src\com\godot\game\GodotApp.java:48: error: package FlurryAgent does not exist
new FlurryAgent.Builder()
^
1 error
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
Did I paste any codes at the wrong files? I pasted the arr into the build.gradle file within the Android folder of my Godot project here;
apply from: 'config.gradle'
buildscript {
apply from: 'config.gradle'
repositories {
google()
mavenCentral()
//CHUNK_BUILDSCRIPT_REPOSITORIES_BEGIN
//CHUNK_BUILDSCRIPT_REPOSITORIES_END
}
dependencies {
classpath libraries.androidGradlePlugin
classpath libraries.kotlinGradlePlugin
//CHUNK_BUILDSCRIPT_DEPENDENCIES_BEGIN
//CHUNK_BUILDSCRIPT_DEPENDENCIES_END
}
}
apply plugin: 'com.android.application'
allprojects {
repositories {
google()
mavenCentral()
//CHUNK_ALLPROJECTS_REPOSITORIES_BEGIN
//CHUNK_ALLPROJECTS_REPOSITORIES_END
// Godot user plugins custom maven repos
String[] mavenRepos = getGodotPluginsMavenRepos()
if (mavenRepos != null && mavenRepos.size() > 0) {
for (String repoUrl : mavenRepos) {
maven {
url repoUrl
}
}
}
}
}
dependencies {
implementation 'com.flurry.android:analytics:13.1.0#aar'
implementation libraries.supportCoreUtils
implementation libraries.kotlinStdLib
implementation libraries.v4Support
if (rootProject.findProject(":lib")) {
implementation project(":lib")
} else if (rootProject.findProject(":godot:lib")) {
implementation project(":godot:lib")
} else {
// Custom build mode. In this scenario this project is the only one around and the Godot
// library is available through the pre-generated godot-lib.*.aar android archive files.
debugImplementation fileTree(dir: 'libs/debug', include: ['*.jar', '*.aar'])
releaseImplementation fileTree(dir: 'libs/release', include: ['*.jar', '*.aar'])
}
And I then pasted the initialising calls to the GodotApp.java file in the src folder of the project. This is where I suspect where I got it wrong;
package com.godot.game;
import org.godotengine.godot.FullScreenGodotApp;
import android.os.Bundle;
/**
* Template activity for Godot Android custom builds.
* Feel free to extend and modify this class for your custom logic.
*/
public class GodotApp extends FullScreenGodotApp {
#Override
public void onCreate(Bundle savedInstanceState) {
setTheme(R.style.GodotAppMainTheme);
super.onCreate(savedInstanceState);
new FlurryAgent.Builder()
.withLogEnabled(true)
.build(this, "9NZTG7YG8GZBP9SY7K89");
}
}
Appreciate it if you can enlighten this clueless newbie. I have very little programming knowledge so certain things are still very foreign to me.
UPDATE:
I've decided to abandon Flurry and just use Firebase instead since there's much more information about it available online. Implemented it to my project within minutes.
In your app's build.gradle file, you need to add Flurry dependency.
// In your main app's Gradle config file:
repositories {
mavenCentral()
}
dependencies {
// Recommended to add Google Play Services
implementation 'com.google.android.gms:play-services-ads-identifier:17.1.0'
// Required for Flurry Analytics integration
implementation 'com.flurry.android:analytics:13.1.0'
}
and in your codes, add
import com.flurry.android.FlurryAgent;
Related
i've been working with firebase to access an activity on my project. Everything works fine, no compilation errors. However after i go to tools > firebase i can connect to my app easily, however when i try to click Add Real time database it shows me this:
build.gradle will include these new dependencies:
compile 'com.google.firebase:firebase-database:16.0.1:15.0.0'
Since compile is deprecated i use implementation, and when i do
Implementation 'com.google.firebase:firebase-database:16.0.1:15.0.0'
i get the following error Failed to resolve: firebase-database-15.0.0
and my sync fails.
Change Root Gradle to
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
}
}
allprojects {
// ...
repositories {
// ...
google() // Google's Maven repository
}
}
And App Gradle To
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
// Getting a "Could not find" error? Make sure you have
// added the Google maven respository to your root build.gradle
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
Hope This May Help You
add jcenter() in your project-level gradle.
allprojects {
repositories {
google()
jcenter()
}
}
and keep remaining as #Tomin B said.
I'm trying to follow the tutorial here: https://cloud.google.com/solutions/mobile/firebase-app-engine-android-studio to create a Google App Engine Module. I followed the first step to use the UI to generate an App Engine Module, but after that I got stuck on the part about adding dependencies. When I try to use File > Project Structure > + > Add Library Dependencies, none of three dependencies listed in the tutorial show up in the list of available libraries. After reading other StackOverflow posts, I tried the following:
I updated Android Studio, Android Build Tools, Google Play services, and the Google Repository to the newest version.
I tried adding the dependencies manually by writing compile statements in the backend module build.gradle file (e.g. compile 'com.google.appengine:appengine-api-1.0-sdk'). Then the sync failed and Android Studio gave me the following error: Failed to resolve: com.google.appengine:appengine-api-1.0-sdk
I tried File > Restart / Invalidate Cache
I tried using Android Studio on a different computer
All this, yet no success. Below are my gradle files, in case they are of use. Although I would be surprised if they would be, since I just followed the app engine part of the tutorial.
// 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.3.1'
// 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
}
backend module build.gradle:
// If you would like more information on the gradle-appengine-plugin please refer to the github page
// https://github.com/GoogleCloudPlatform/gradle-appengine-plugin
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.appengine:gradle-appengine-plugin:1.9.42'
}
}
repositories {
jcenter();
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.42'
compile 'javax.servlet:servlet-api:2.5'
compile 'com.google.appengine:appengine-api-1.0-sdk'
compile 'com.google.firebase:firebase-server-sdk'
compile 'org.apache.httpcomponents:httpclient'
}
appengine {
downloadSdk = true
appcfg {
oauth2 = true
}
}
Android Studio gives me the error message mentioned above on the last three dependencies in the above file when I try to sync. Any help would be appreciated. Thanks.
To simplify things I'm going to call the libraries I'm using library_a.aar and library_b.aar.
Here is the scenario that I'm facing.
library_a is build and pushed to maven_repository and no problems here.
library_b depends on library_a and added to library_b as follows:
repositories {
maven {
credentials {
username USERNAME
password PASSWORD
}
url "https://api.bitbucket.org/1.0/repositories/COMPANY/maven_repository/raw/releases"
}
}
dependencies {
...
compile 'package:library_a:1.0'
...
}
library_b is built with no errors and uploaded to the maven_repository.
Now my application depends on library_b which I need to add by providing (as above) the repository along with the credentials.
The first issue that I'm facing is that in order to compile library_b in my project it needs to be compiled in the following way:
dependencies {
...
compile 'package:library_b:1.0#aar'
...
}
I have to add the #aar otherwise gradle won't recognize it, but I didn't have to do that with library_a.
The second issue is that when I build the app I get warnings that it can't find references to classes available in library_a. What am I missing over here? I did try to add transitive=true to library_a
dependencies {
...
compile ('package:library_a:1.0') {
transitive = true;
}
...
}
but absolutely nothing works. I did check the pom file and it includes the proper dependencies.
Could it be that what I'm doing is not supported by gradle and I have to compile both library_a and library_b in my app?
Sounds like your maven repo only contains the aar files but no or wrong pom files.
Are you using the following gradle plugin and the uploadArchives gradle task in order to upload the aars to your maven repository?
https://github.com/dcendents/android-maven-gradle-plugin
try this gradle snippet for your aars:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
}
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
android { ... }
dependencies { ... }
uploadArchives {
repositories {
mavenDeployer {
repository(url: "https://api.bitbucket.org/1.0/repositories/COMPANY/maven_repository/raw/releases") {
authentication(userName: USERNAME, password: PASSWORD)
}
}
}
}
Then use the uploadArchives gradle task
I'm trying to generate .java files from the .proto files I have stored under my SRC folder in Android studio. I put the below code in my gradle file by it doesn't seem to work
apply plugin: 'com.squareup.wire'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.squareup.wire:wire-maven-plugin:2.1.1'
}
}
There is a gradle plugin for wire here: https://github.com/square/wire-gradle-plugin. However, it seems like it's not quite ready for primetime yet. I had some trouble getting it working.
But, here's a way to do it that automates generation of java code from the *.proto files using the wire compiler directly and a simple gradle task. I've provided a snippet below with the modifications to your build.gradle. Change the protoPath and wireGeneratedPath based on your source layout.
def protoPath = 'src/proto'
def wireGeneratedPath = 'build/generated/source/wire'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.squareup.wire:wire-compiler:2.2.0'
}
}
android {
sourceSets {
main {
java {
include wireGeneratedPath
}
}
}
}
dependencies {
compile 'com.squareup.wire:wire-runtime:2.2.0'
// Leave this out if you're not doing integration testing...
androidTestCompile 'com.squareup.wire:wire-runtime:2.2.0'
}
// This handles the protocol buffer generation with wire
task generateWireClasses {
description = 'Generate Java classes from protocol buffer (.proto) schema files for use with squareup\'s wire library'
delete(wireGeneratedPath)
fileTree(dir: protoPath, include: '**/*.proto').each { File file ->
doLast {
javaexec {
main = 'com.squareup.wire.WireCompiler'
classpath = buildscript.configurations.classpath
args = ["--proto_path=${protoPath}", "--java_out=${wireGeneratedPath}", "${file}"]
}
}
}
}
preBuild.dependsOn generateWireClasses
So instead of using a gradle plugin I just ended up using the square wire compiler jar. Here are the steps.
Download compiler-jar-with-dependencies from http://search.maven.org/#artifactdetails%7Ccom.squareup.wire%7Cwire-compiler%7C2.1.1%7Cjar
Put jar file into root directory of android app
Go to the directory and paste this command
java -jar wire-compiler-2.1.1-jar-with-dependencies.jar --proto_path=directory-of-protofile --java_out=app/src/main/java/ name-of-file.proto
Should work. Make sure to replace the directory-of-protofile and name-of-file with whatever you have.
Just when I'd achieved an effective development and build environment with the android-maven-plugin, the new kid on the block, Gradle, starts making inroads into the Android circles. Not being hot on Groovy and with the android-gradle plugin almost as fragmented as the OS itself I've hit some issues. Specifically around building library projects, with flavours and our buddy Robolectric.
Short version
I am at a loss as to what my next move should be upon encountering the gradle error;
Cannot add a SourceSet with name 'testDebug' as a SourceSet with that name already exists.
The error emanates from having productFlavours on a library (i.e. moving to the 0.9.2 android build system) and the gradle-android-test-plugin recently forked by the team over at Robolectric from Jake's creation (see here). I have followed all lines of investigation to near exhaustion and can report that the meer existence of the 'android-test' plugin within my library gradle file sends things awry.
Longer version
Here is the abridged application build.gradle file with pertinent information retained;
apply plugin: 'android-library'
apply plugin: 'android-test'
...
android {
compileSdkVersion 19
buildToolsVersion '19.0.3'
defaultConfig {
minSdkVersion 18
targetSdkVersion 19
versionCode buildNumber().toInteger()
versionName "1.0.0"
}
productFlavors {
estimote {
dependencies {
compile '<flavour specific dependency>'
}
}
radius {
dependencies {
compile '<flavour specific dependency>'
}
}
}
}
...
dependencies {
compile 'com.squareup.dagger:dagger:1.2.1'
compile 'com.squareup.dagger:dagger-compiler:1.2.1'
compile 'com.google.code.gson:gson:2.2.+'
// Testing dependencies
androidTestCompile 'org.mockito:mockito-core:1.9.5'
androidTestCompile 'com.squareup:fest-android:1.0.7'
androidTestCompile 'org.hamcrest:hamcrest-all:1.3'
androidTestCompile 'org.robolectric:robolectric:2.2'
androidTestCompile 'junit:junit:4.11'
}
And here is the abridged root build.gradle file.
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.2'
classpath 'org.robolectric.gradle:gradle-android-test-plugin:0.9.+'
}
}
allprojects {
repositories {
mavenLocal()
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
}
}
If you've got this far down the page, give yourself a pat on the back. Now, the eagle eyed amongst you have probably noticed the omission on the sourceSets redirection with commands akin to;
sourceSets {
androidTest {
setRoot('src/test')
}
}
After the initial error is corrected these lines will need to be reinstated to inform gradle of the project's structure. The project's structure is standard and looks like;
- project_name
+ gradle
- lib
+ flavour1
+ flavour2
- main
+ java
- test
+ java
build.gradle
build.gradle
gradle.properties
settings.gradle
What is being used
The app is using gradle-1.10-all, 0.9.2 android-gradle plugin and 0.9.+ gradle-android-test-plugin.
The question
How should the project be set-up/changed to facilitate Robolectric testing on a library with flavours? Is this even possible yet?
I ran into the same issue, dug into the code, fixed it, and submitted a pull request which has just now been merged. See my explanation on the PR for details, but it boils down to a bad optimization in the plugin code:
https://github.com/robolectric/robolectric-gradle-plugin/pull/70
As of today you need to clone the repo and build and install the plugin to your local maven repo. The next time they do a release to maven central (perhaps release 0.13.1?), you'll be able to use the plugin directly from there.