Java Question Help (SumUp SDK Library Wrapper)

walterf25

Expert
Licensed User
Longtime User
Hi All, i am working on wrapping a library for a client, the jar file and xml file compile just fine, i have copied both files to my /additionallibraries folder but when I run an example app to test the library i get the following errors:
Generating R file. Error
C:\Android_SDK\tools\..\extras\b4a_local\unpacked-merchant-sdk-3.2.2.androidx-63730710555924\res\layout\fragment_signature_view.xml:36: error: Error: No resource found that matches the given name (at 'layout_toStartOf' with value '@id/cc_number').
C:\Android_SDK\tools\..\extras\b4a_local\unpacked-merchant-sdk-3.2.2.androidx-63730710555924\res\layout\fragment_signature_view.xml:36: error: Error: No resource found that matches the given name (at 'layout_toLeftOf' with value '@id/cc_number').
C:\Android_SDK\tools\..\extras\b4a_local\unpacked-merchant-sdk-3.2.2.androidx-63730710555924\res\layout\fragment_tx_failed.xml:13: error: Error: No resource found that matches the given name (at 'layout_above' with value '@id/transaction_status').
C:\Android_SDK\tools\..\extras\b4a_local\unpacked-merchant-sdk-3.2.2.androidx-63730710555924\res\layout\fragment_tx_failed.xml:23: error: Error: No resource found that matches the given name (at 'layout_above' with value '@id/transaction_status').
C:\Android_SDK\tools\..\extras\b4a_local\unpacked-merchant-sdk-3.2.2.androidx-63730710555924\res\layout\fragment_tx_failed.xml:75: error: Error: No resource found that matches the given name (at 'layout_above' with value '@id/call_support_message').
C:\Android_SDK\tools\..\extras\b4a_local\unpacked-merchant-sdk-3.2.2.androidx-63730710555924\res\layout\fragment_tx_failed.xml:96: error: Error: No resource found that matches the given name (at 'layout_above' with value '@id/btn_dismiss').
C:\Android_SDK\tools\..\extras\b4a_local\unpacked-merchant-sdk-3.2.2.androidx-63730710555924\res\layout\fragment_tx_success.xml:138: error: Error: No resource found that matches the given name (at 'layout_above' with value '@id/receipt_button_layout').
C:\Android_SDK\tools\..\extras\b4a_local\unpacked-merchant-sdk-3.2.2.androidx-63730710555924\res\layout\fragment_tx_success.xml:145: error: Error: No resource found that matches the given name (at 'id' with value '@id/receipt_button_layout').

I have copied the merchan-sdk-3.2.2.aar file to the /additionallibraries folder as well and I have jetified the file also, I'm not sure if there's anything else I need to add to the manifest file, as there's nothing in the documentation about adding anything else.

I know i may not be providing too much details as even I'm very confused about this issue, normally when I wrap libraries I've never had this type of issues before, according to their documentation the following code is all that is needed to initialize the SDK.
Java:
    public class SampleApplication extends Application {
    
    @Override
    public void onCreate() {
        super.onCreate();
        SumUpState.init(this);
    }

the java code for the wrapper is as follows:
Java:
    public void Initialize(BA ba, String EventName) {
        mba = ba;
        mEventName = EventName.toLowerCase(BA.cul);
        SumUpState.init(mba.activity);
    }

In the wrapper the library DependsOn merchant-sdk-3.2.2.aar file
I'm using the latest B4A version.

Hope someone can give me a hint about what I may be doing wrong.

Thanks,
Walter
 

walterf25

Expert
Licensed User
Longtime User

DonManfred

Expert
Licensed User
Longtime User
Where is the Link to SumUps Documentation, Example Project, AAR Files?
 

walterf25

Expert
Licensed User
Longtime User

DonManfred

Expert
Licensed User
Longtime User
You are aware that the Manifest from the AAR does not take into account when using B4A.
You need to add the needed Manifestchanges by yourself to the Manifesteditor to be able to access the Activities mentioned in the AARs Manifest.

B4X:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.sumup.merchant"
    android:installLocation="auto"
    android:versionCode="193231518"
    android:versionName="3.2.2" >

    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="28" />

    <uses-permission android:name="android.permission.INTERNET" /> <!-- for google analytics -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.NFC" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" /> <!-- Implied due to requested permissions but not really needed -->
    <uses-feature
        android:name="android.hardware.camera"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.location.gps"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.location.network"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.microphone"
        android:required="false" /> <!-- Also implied, but also really needed -->
    <uses-feature
        android:name="android.hardware.touchscreen"
        android:required="true" />
    <uses-feature
        android:name="android.hardware.screen.portrait"
        android:required="true" /> <!-- any location is good enough for us -->
    <uses-feature
        android:name="android.hardware.location"
        android:required="true" /> <!-- Only necessary because of missing checks. See: APPS-801 -->
    <uses-feature
        android:name="android.hardware.bluetooth"
        android:required="true" />

    <application>
        <activity
            android:name="com.sumup.merchant.api.LoadSumUpPaymentsActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/sumup_title_pay_with_sumup"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.sumup.merchant.api.LoadSumUpPaymentSettingsActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/sumup_navigation_payment_methods"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.sumup.merchant.ui.Activities.LoginActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:exported="true"
            android:launchMode="singleTop"
            android:screenOrientation="portrait"
            android:theme="@style/SumUpThemeLegacy.WhiteBar.Login"
            android:windowSoftInputMode="adjustResize" >
        </activity>
        <activity
            android:name="com.sumup.merchant.ui.Activities.DevSetupActivity"
            android:screenOrientation="portrait"
            android:theme="@style/SumUpTheme.ActionBarNoShadow" />
        <activity
            android:name="com.sumup.merchant.ui.Activities.CheckoutAPIDrivenPageActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:screenOrientation="portrait"
            android:theme="@style/SumUpThemeLegacy"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name="com.sumup.merchant.ui.Activities.PaymentSettingsActivity"
            android:label="@string/sumup_navigation_payment_methods"
            android:screenOrientation="portrait"
            android:theme="@style/SumUpThemeLegacy" />
        <activity
            android:name="com.sumup.merchant.ui.Activities.PinPlusSetupActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:screenOrientation="portrait" />
        <activity
            android:name="com.sumup.merchant.ui.Activities.BtTroubleshootingActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:screenOrientation="portrait"
            android:theme="@style/SumUpThemeLegacy.WithTranslucentActionBar" />
        <activity
            android:name="com.sumup.merchant.ui.Activities.SendSmsActivity"
            android:screenOrientation="portrait"
            android:theme="@style/SumUpThemeLegacy" />

        <service
            android:name="com.sumup.merchant.print.ReceiptPrintService"
            android:exported="false" />
    </application>

</manifest>

There are a lot of activities mentioned.
Also note that you need to rewrite some parts in the way B4A is using them. Adding the permissions for example.
 
Last edited:

walterf25

Expert
Licensed User
Longtime User
You are aware that the Manifest from the AAR does not take into account when using B4A.
You need to add the needed Manifestchanges by yourself to the Manifesteditor to be able to access the Activities mentioned in the AARs Manifest.

B4X:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.sumup.merchant"
    android:installLocation="auto"
    android:versionCode="193231518"
    android:versionName="3.2.2" >

    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="28" />

    <uses-permission android:name="android.permission.INTERNET" /> <!-- for google analytics -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.NFC" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" /> <!-- Implied due to requested permissions but not really needed -->
    <uses-feature
        android:name="android.hardware.camera"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.location.gps"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.location.network"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.microphone"
        android:required="false" /> <!-- Also implied, but also really needed -->
    <uses-feature
        android:name="android.hardware.touchscreen"
        android:required="true" />
    <uses-feature
        android:name="android.hardware.screen.portrait"
        android:required="true" /> <!-- any location is good enough for us -->
    <uses-feature
        android:name="android.hardware.location"
        android:required="true" /> <!-- Only necessary because of missing checks. See: APPS-801 -->
    <uses-feature
        android:name="android.hardware.bluetooth"
        android:required="true" />

    <application>
        <activity
            android:name="com.sumup.merchant.api.LoadSumUpPaymentsActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/sumup_title_pay_with_sumup"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.sumup.merchant.api.LoadSumUpPaymentSettingsActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/sumup_navigation_payment_methods"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.sumup.merchant.ui.Activities.LoginActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:exported="true"
            android:launchMode="singleTop"
            android:screenOrientation="portrait"
            android:theme="@style/SumUpThemeLegacy.WhiteBar.Login"
            android:windowSoftInputMode="adjustResize" >
        </activity>
        <activity
            android:name="com.sumup.merchant.ui.Activities.DevSetupActivity"
            android:screenOrientation="portrait"
            android:theme="@style/SumUpTheme.ActionBarNoShadow" />
        <activity
            android:name="com.sumup.merchant.ui.Activities.CheckoutAPIDrivenPageActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:screenOrientation="portrait"
            android:theme="@style/SumUpThemeLegacy"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name="com.sumup.merchant.ui.Activities.PaymentSettingsActivity"
            android:label="@string/sumup_navigation_payment_methods"
            android:screenOrientation="portrait"
            android:theme="@style/SumUpThemeLegacy" />
        <activity
            android:name="com.sumup.merchant.ui.Activities.PinPlusSetupActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:screenOrientation="portrait" />
        <activity
            android:name="com.sumup.merchant.ui.Activities.BtTroubleshootingActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:screenOrientation="portrait"
            android:theme="@style/SumUpThemeLegacy.WithTranslucentActionBar" />
        <activity
            android:name="com.sumup.merchant.ui.Activities.SendSmsActivity"
            android:screenOrientation="portrait"
            android:theme="@style/SumUpThemeLegacy" />

        <service
            android:name="com.sumup.merchant.print.ReceiptPrintService"
            android:exported="false" />
    </application>

</manifest>

There are a lot of activities mentioned
Where did you get this from? I totally missed it, is this in the same github link I shared with you?

Walter
 

walterf25

Expert
Licensed User
Longtime User
I checked the AAR File content. I found it in the merchant-sdk-3.2.2.aar file

I downloaded them from

I added all the manifest file entries, and now the app compiles fine, but when I try to Initialize the SDK I get the following error in the Logs, I checked the unfiltered logs but don't see anything related to this issue:

android.content.res.Resources$NotFoundException: String resource ID #0x0

Seems like I may still be missing more resources, however I am referencing the AdditionalJar: merchant-sdk-3.2.2.aar file, any other hints?

Walter
 

walterf25

Expert
Licensed User
Longtime User
Adding some more information about this issue, I have made sure i have all the library dependencies on my library project, however i still continue getting the following error when trying to Initialize the SumUpState method:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
PackageName: com.example.app
Error occurred on line: 82 (Main)
android.content.res.Resources$NotFoundException: String resource ID #0x0
at android.content.res.Resources.getText(Resources.java:402)
at android.content.res.Resources.getString(Resources.java:495)
at android.content.Context.getString(Context.java:641)
at com.sumup.merchant.util.EnvironmentUtil.getAPIUrlForEnvironment(SourceFile:171)
at com.sumup.merchant.util.EnvironmentUtil.getEnvironment(SourceFile:152)
at com.sumup.merchant.CoreState.<init>(SourceFile:141)
at com.sumup.merchant.CoreState.init(SourceFile:86)
at com.sumup.merchant.api.SumUpState.init(SourceFile:10)
at com.sumup.merchant.HiDataSumUp.SumUpStateInit(HiDataSumUp.java:44)
at com.example.app.main._btnlogin_click(main.java:430)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:7869)
at android.widget.TextView.performClick(TextView.java:14958)
at android.view.View.performClickInternal(View.java:7838)
at android.view.View.access$3600(View.java:886)
at android.view.View$PerformClick.run(View.java:29362)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8034)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)
** Activity (main) Pause, UserClosed = true **
** Service (starter) Destroy (ignored)**

One thing I noticed by inspecting the R.Java file generated by B4A is that it's missing a lot of the items that should be included in that file, how can this be possible, how does B4A know what items to include in the R.Java file, I see there are several but none of them contain the missing items, for example it is missing the following:
XML:
int id receipt_button_layout
int id cc_number
And a lot others, I think this may be the cause of the issue i'm having, as i mentioned in my first post, I have all the .aar files needed as dependencies for this Library, maybe @Erel can chime in and give us some hints as to what could possible be going on.

I am attaching the R.txt file that is included in the merchant-sdk-3.2.2.aar file so you guys can have an idea of what are the resources that need to be included in the B4A project.

And I am also attaching the R.java file generated by B4A
If you look at both files, you'll see that the generated R.java file is missing a lot of the resources included in the R.txt file which i extracted from the .aar SDK file.

R.java file

Hope this information is helpful to anyone else following this thread.

Walter
 

Attachments

  • R.txt
    201.2 KB · Views: 337
Last edited:

Lucas Siqueira

Active Member
Licensed User
Longtime User
Adding some more information about this issue, I have made sure i have all the library dependencies on my library project, however i still continue getting the following error when trying to Initialize the SumUpState method:


One thing I noticed by inspecting the R.Java file generated by B4A is that it's missing a lot of the items that should be included in that file, how can this be possible, how does B4A know what items to include in the R.Java file, I see there are several but none of them contain the missing items, for example it is missing the following:
XML:
int id receipt_button_layout
int id cc_number
And a lot others, I think this may be the cause of the issue i'm having, as i mentioned in my first post, I have all the .aar files needed as dependencies for this Library, maybe @Erel can chime in and give us some hints as to what could possible be going on.

I am attaching the R.txt file that is included in the merchant-sdk-3.2.2.aar file so you guys can have an idea of what are the resources that need to be included in the B4A project.

And I am also attaching the R.java file generated by B4A
If you look at both files, you'll see that the generated R.java file is missing a lot of the resources included in the R.txt file which i extracted from the .aar SDK file.

R.java file

Hope this information is helpful to anyone else following this thread.

Walter

Hi, did you manage to get it to work? Can you share how you did it?

I'm having some errors when trying to compile with the sumup lib



erro:
B4A Version: 12.50
Parsing code.    (0.04s)
    Java Version: 14
Building folders structure.    (0.02s)
Compiling code.    (0.05s)
Compiling layouts code.    (0.01s)
Organizing libraries.    (0.03s)
    (AndroidX SDK)
Compiling resources    Error
C:\B4X\ANDROID\tools\..\extras\b4a_local\unpacked-merchant-sdk-4.3.0-63834812724925\res\values-en\values-en.xml:34: error: multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?.
C:\B4X\ANDROID\tools\..\extras\b4a_local\unpacked-merchant-sdk-4.3.0-63834812724925\res\values-en\values-en.xml: error: file failed to compile.
C:\B4X\ANDROID\tools\..\extras\b4a_local\unpacked-merchant-sdk-4.3.0-63834812724925\res\values\values.xml:217: error: multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?.
C:\B4X\ANDROID\tools\..\extras\b4a_local\unpacked-merchant-sdk-4.3.0-63834812724925\res\values\values.xml: error: file failed to compile.
 

walterf25

Expert
Licensed User
Longtime User
Hi, did you manage to get it to work? Can you share how you did it?

I'm having some errors when trying to compile with the sumup lib



erro:
B4A Version: 12.50
Parsing code.    (0.04s)
    Java Version: 14
Building folders structure.    (0.02s)
Compiling code.    (0.05s)
Compiling layouts code.    (0.01s)
Organizing libraries.    (0.03s)
    (AndroidX SDK)
Compiling resources    Error
C:\B4X\ANDROID\tools\..\extras\b4a_local\unpacked-merchant-sdk-4.3.0-63834812724925\res\values-en\values-en.xml:34: error: multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?.
C:\B4X\ANDROID\tools\..\extras\b4a_local\unpacked-merchant-sdk-4.3.0-63834812724925\res\values-en\values-en.xml: error: file failed to compile.
C:\B4X\ANDROID\tools\..\extras\b4a_local\unpacked-merchant-sdk-4.3.0-63834812724925\res\values\values.xml:217: error: multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?.
C:\B4X\ANDROID\tools\..\extras\b4a_local\unpacked-merchant-sdk-4.3.0-63834812724925\res\values\values.xml: error: file failed to compile.
I managed to get it working but honestly it's been a while and don't recall how exactly I got it working.
 
Top