Java Question Error create library with SLC

Situ LLC

Active Member
Licensed User
Starting step: Compiling Java code.
D:\Basic4android Proyectos\my_wrapper\as_wrapper\app\src\androidTest\java\com\example\my_wrapper\ExampleInstrumentedTest.java:5: error: package androidx.test.platform.app does not exist
import androidx.test.platform.app.InstrumentationRegistry;
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
How do you expect anyone can help you with the Informations you provide?
- Upload the source of your library you want to compile with SLC
- Post the FULL compilewindow output from SLC.
 

Situ LLC

Active Member
Licensed User
I am creating a lib with SLC and I get this error message:

Starting step: Compiling Java code.
D:\Basic4android Proyectos\my_wrapper\as_wrapper\app\src\androidTest\java\com\example\my_wrapper\ExampleInstrumentedTest.java:5: error: package androidx.test.platform.app does not exist
import androidx.test.platform.app.InstrumentationRegistry;


package com.example.my_wrapper;

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry; <---- This Line
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();

assertEquals("com.example.my_wrapper", appContext.getPackageName());
}
}
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Open B4A Sdk Manager.
2. Search for androix.test and install the various components.
3. Create an empty project in B4A, add #AdditionalJar: androidx.test:monitor
4. Run the project
5. The jar file with the required class will be located in:
C:\android-sdk\extras\b4a_remote\androidx\test\monitor\1.2.0\unpacked-monitor-1.2.0\jars\classes.jar

You will need to copy it to the libs folder. It is only needed during compilation. The library should include @DependsOn(values={"androidx.test:monitor"})
 
Top