Android Extension breaks the build!

For the first time I am writing an Android Extension and following this tutorial

However running the project breaks the build with following message.

FAILURE: Build failed with an exception.

 What went wrong:
A problem occurred configuring project ':app'.
> A problem occurred configuring project ':deps:setbrightness'.
   > Could not resolve all dependencies for configuration ':deps:setbrightness:classpath'.
      > Could not find
        Searched in the following locations:
        Required by:

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


Any help would be a nice help.

Oh, yeah. I noticed that a couple months back, but I guess we never did anything about it.

I should go follow up on that. In the meantime, all you need to do is open up SetBrightness/dependencies/android/build.gradle, find the line that looks like this:

classpath ''

…and change it to this:

classpath ''

thanks @player_03 for the response.

The trick is not working. just tried it and got the exact same error message!

Can you post what you see in Export/android/debug/bin/deps/SetBrightness/build.gradle?

thanks @player_03. Here is the build.gradle

 buildscript {
	repositories {
		maven {
			url ""
	dependencies {
		classpath ''

apply plugin: ''

android {
	compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
	buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION

dependencies {
	compile project(':deps:extension-api')

But the path is android\release\bin\deps\setbrightness

Looks like you pasted this:

classpath ''

…instead of this:

classpath ''

You need all three colons in a row, since two will be removed, and you want to have one left over.

Ahh! Thanks.
Now I get past the old error but got a new one.

Export\android\release\bin\deps\setbrightness\src\main\java\org\haxe\extension\ package WindowManager does not exist
            WindowManager.LayoutParams layout = Extension.mainActivity.getWindow().getAttributes();
1 error
:deps:setbrightness:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':deps:setbrightness:compileReleaseJavaWithJavac'.
> 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.


Well, actually my code is as below

	public static void setBrightness(float brightness) {
	    WindowManager.LayoutParams layout = Extension.mainActivity.getWindow().getAttributes();
	    layout.screenBrightness = brightness;



import android.view.WindowManager;

to the top of file, or change

WindowManager.LayoutParams layout = Extension.mainActivity.getWindow().getAttributes();


android.view.WindowManager.LayoutParams layout = Extension.mainActivity.getWindow().getAttributes();

thanks a lot @restorer that did the trick.
Next question :slight_smile:

Now everything compiles but application is not launching if I call

But if I do not call this, then the application launches!

Thank you all for the help. The extension is now compiling fine.

But the application crashes, once I call the extension method.

Here are the codes

public static void testToast(int iVal){
		Toast.makeText(Extension.mainContext, "OpenFL : Toast", 5000).show();

Haxe extension

private static var testToastJNI = JNI.createStaticMethod("org.haxe.extension.SetBrightness", "testToast", "(I)V");	
	public static function testToast(testVal:Int):Void{
		trace('Extension Called : testToast : '+testVal);

Finally I am calling as this.


As soon as the last one is called, application crashes!

Figured out.

First of all

import openfl.utils.JNI;


import lime.system.JNI;

Second, the java code must be inside Runnable as mentioned here.

1 Like