Skip to content

Android error: missing method body, or declare abstract #575

@martinkbrown

Description

@martinkbrown

I'm trying to run the Android example found in BridJ/Examples/AndroidExample. I am able to get dependencies resolved after downloading BridJ and using maven to build it successfully. I place the generated bridj-0.7.1-SNAPSHOT-andorid.jar in app/libs, and I place everything under BridJ/src/main/android-libs in app/src/main/jniLibs. I copy the files in BridJ/Examples/AndroidExample/ to my Android project. All of the BridJ dependencies are resolved.

The problem is that MainActivity won't compile. The error on

public static void helloLog(Pointer<Byte> logThis);

says "Missing method body, or declare abstract". If I declare the method to be native, then I get the following runtime error.

java.lang.UnsatisfiedLinkError: No implementation found for void yada.yada.yada.MainActivity.helloLog(org.bridj.Pointer) (tried Java_yada_yada_yada_MainActivity_helloLog and Java_yada_yada_yada_MainActivity_helloLog__Lorg_bridj_Pointer_2)

I haven't added or removed anything from MainActivity.java, but for what it's worth, I'm pasting the source for that below. Any ideas?

package yada.yada.yada;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

import java.io.IOException;

import org.bridj.BridJ;
import org.bridj.NativeLibrary;
import org.bridj.Pointer;
import org.bridj.ann.Library;
import org.bridj.demangling.Demangler.Symbol;

import static org.bridj.Pointer.pointerToCString;

public class MainActivity extends Activity {

	static final String TAG = MainActivity.class.getName();

	@Library("example")
	public static void helloLog(Pointer<Byte> logThis);

	static {
		BridJ.register();
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		helloLog(pointerToCString("Hello, World!"));
		try {
			NativeLibrary lib = BridJ.getNativeLibrary("example");
			for (Symbol s : lib.getSymbols()) {
				String p = s.getParsedRef() + "";
				System.out.println(p);
			}
		} catch (IOException e) {
			throw new RuntimeException("BridJ loading failed?", e);
		}
		setContentView(R.layout.activity_main);
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions