Unable to build Android


#1

Hi guys,

I am trying to update an old app (v2.5.x) to the current one.

When I call forge build android I see this message, but there are no docs enteries about this:

  • What went wrong:
    Execution failed for task ‘:ForgeInspector:preVanillaReleaseBuild’.
    Android dependency ‘com.android.support:appcompat-v7’ has different version for the compile (22.0.0) and runtime (28.0.0) classpath. You should manually set the same version via DependencyResolution

I am new to trigger.io so no idea where to look


#2

This is probably caused by module incompatibilities.

Make sure your app is on the latest Forge version (v.2.7.8) and all your modules have been updated to the latest versions.

If you’re still having an issue, please attach your src/config.json file to a post.

(Attach it as a file, don’t copy & paste! The forum software detroys the format if you try include it directly!)


#4

I have this one custom module, I have rebuiled this with current sdk still I have this error, any idea? I have this error only if I compile it with this module.

config of the app

{
	"config_version": "4",
	"name": "...",
	"author": "...",
	"version": "1.3.0",
	"platform_version": "v2.7.8",
	"description": "...",
	"core": {
		"general": {
			"logging": {
				"level": "WARNING"
			}
		},
		"android": {
			"package_name": "...",
			"minimum_version": "25"
		},
		"ios": {
			"disable_web_storage_backup": true,
			"package_name": "...",
			"webview": "WKWebView",
			"device_family": "iphone"
		}
	},
	"modules": {
		"platform": {
			"version": "2.3"
		},
		"file": {
			"version": "2.23",
			"config": {
				"usage_description": "This app needs to store your travel documents, e.g. the voucher, on the device."
			}
		},
		"display": {
			"version": "2.11",
			"config": {
				"orientations": {
					"ipad": "portrait",
					"android": "portrait",
					"iphone": "portrait"
				}
			}
		},
		"notification": {
			"version": "2.8"
		},
		"prefs": {
			"version": "2.2"
		},
		"tabs": {
			"version": "2.23"
		},
		"browsersettings": {
			"version": "1.6",
			"config": {
				"accept_cookies": true
			}
		},
		"android_screen_size": {
			"version": "0.0.3",
			"disabled": true
		},
		"intent_manager": {
			"version": "0.3.1",
			"disabled": true
		},
		"file_with_headers": {
			"version": "0.2.1",
			"disabled": true
		},
		"ga": {
			"version": "0.1.1",
			"disabled": true
		},
		"pushnotifications": {
			"version": "0.1.17",
			"disabled": true
		}
	},
	"homepage": "..."
}

module config

{

"description": "Google Analytics SDK",

"min_platform_version": "v2.7.8",

"namespace": "ga",

"platform_version": "v2.7.8",

"version": "0.1.1"

}

#5

Ah okay, then you’ll probably need to check your custom module and make sure that any dependencies you’re using match whatever we’re using in the Forge runtime:

Android Support library version: v28.0.0
Compile SDK version: 28
Google services: 4.2.0

I haven’t worked with the Google Analytics SDK so there’s not much else I can offer in terms of advice.


#6

I have done some research:

> Android dependency 'com.android.support:appcompat-v7' has different version for the compile (26.1.0) and runtime (28.0.0) classpath. You should manually set the same version via DependencyResolution

https://github.com/flutter/flutter/issues/14020

some people suggest to add

    implementation "com.android.support:support-v4:27.1.1" // added this

and some

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "26.1.0"
            }
        }
    }
}

can this be done with build_steps.json or is there a way to accomplish this somehow with trigger.io?
Usually I can change the java code to fix problems like this :slight_smile:


#7

Even if you could add custom gradle rules to force override dependencies I’d advise strongly against it as it will create even more issues for you down the line and we would no longer be able to offer you any level of support with your app.

Also take note that the next major release of Android (and therefore Forge v2.8.x) will be deprecating the com.android.support.* namespace entirely in favour of the new androidx namespace.

You will need to fix this at the source by bringing your custom module and any dependencies it may have up to date with the rest of the Android ecosystem.


#8

Hm, but all I do I am adding this line in build_steps

{
    "do": {
        "android_add_gradle_dependency": "com.google.android.gms:play-services:7.5.0"
    }
}

There is a conflict… ok, the only sad thing is, ios is working fine.

Then maybe an update will help:

{
    "do": {
        "android_add_gradle_dependency": "com.google.android.gms:play-services-analytics:17.0.0"
    }
}

nope…

* What went wrong:
Execution failed for task ':ForgeInspector:processVanillaReleaseManifest'.

Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from AndroidManifest.xml:21:43-87
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add ‘tools:replace=“android:appComponentFactory”’ to element at AndroidManifest.xml:8:5-21:954 to override.

adding the replace commando does not help. Maybe this should be added to the app? But the app does not support build steps, or isn’t it?


#9

The very latest Google lib versions have already dropped support for com.android.support in favour of androidx.

Forge v2.8.x brings support for this but it’s still in alpha.

If you’re feeling brave you can try developing your module against Forge platform version: v2.8.0

Change logs can be found here:

https://trigger.io/docs/current/api/beta_release_notes.html


#10

@antoinevg Hi, I am still trying to fix this this issue… alpha is not really an option for us.

But I have an issue with my approaches.

I managed to build a module, but I had to make some changes in gradle script… when I execute the test app, all methods are working fine. But when I test it within my app I have a creash each time I execute a method inside the module.

Is i crashing with messages like: can’t find a class Google/… looks for me, like the packaged app does not contain google play services I have added to module.

Due lack of understanding how the build process works I am not really able to verify what the problem is… can you help me with this? Might the fixes inside gradle be an reason for this? How can I fix this? There are no build steps for gradle.


#11

Take a look at how the parse module is setup. It’s been updated for v2.8.x and is a good demonstration of how to integrate Google Play services:


#12

Thx, this helps a bit… I have created a gist:

this is almost the 1:1 as generated, but I need to make some adjustments to be able to run it.

ForgeInspector_build.gradle I have added line 13
ForgeModule_build.gradle I have added line 72

when I start it, it is working,

I am starting a method to exec this code:

InstanceID instanceID = InstanceID.getInstance(ForgeApp.getActivity());
                token = instanceID.getToken(
                        authorizationEntity,
                        GoogleCloudMessaging.INSTANCE_ID_SCOPE,
                        null
                );

I am getting the token and all is fine.
How ever, when I call the same method in my app:

Process: de.myapp.app.de, PID: 27412
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/iid/InstanceID;
at io.trigger.forge.android.modules.pushnotifications.API$1.run(Unknown Source:4)

looks for me, like the lib was not included in to the build.

I also have tried to add this to build steps

{ "do": { "android_add_gradle_dependency": "com.google.android.gms:play-services:11.0.4"    } },

instead of added this to gradle manually, seems to work as standalone, but when I test it inside the app, I ended up with this error:

  • What went wrong: Execution failed for task ‘:ForgeInspector:preVanillaReleaseBuild’. > Android dependency ‘com.android.support:appcompat-v7’ has different version for the compile (25.2.0) and runtime (28.0.0) classpath. You should manually set the same version via DependencyResolution

#13
  1. You cannot modify the build.gradle files directly. Any changes you wish to apply have to be made via entries in your module/android/build_steps.json file. See the documentation: Changing build configuration
  2. Why are you trying to use an ancient version the Google Play dependencies? It won’t be compatible with Android 29, androidx or pretty much anything else!