Android Question Solved - B4A - Access to DropBox. File manifest and substitute "xxx" with...?

Sabotto

Well-Known Member
Licensed User
I'm getting the error message for the XML file.
B4X:
Sub btnStartOAuth_Click
    auth.startOAuth2Authentication
End Sub

Error occurred on line: 108 (Main)
java.lang.IllegalStateException: URI scheme in your app's manifest is not set up correctly. You should have a com.dropbox.core.android.AuthActivity with the scheme: db-xxx
ecc ecc....

The two points that are not clear to me are:

1) Where exactly in the manifest file should I insert this piece of xml? At the beginning? At the end? Or at a specific point?

XML:
AddApplicationText(<activity
android:name="com.dropbox.core.android.AuthActivity"
android:configChanges="orientation|keyboard"
android:launchMode="singleTask" >
<intent-filter>
<data android:scheme="db-xxx" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>)

My File Manifest is this

XML:
<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="b4a.MioDropbox"
    android:versionCode="1"
    android:versionName=""
    android:installLocation="internalOnly">
   
    <uses-sdk android:minSdkVersion="5" android:targetSdkVersion="28"/>
    <supports-screens android:largeScreens="true"
        android:normalScreens="true"
        android:smallScreens="true"
        android:anyDensity="true"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
    <application
        android:icon="@drawable/icon"
        android:label="Mio Dropbox"
        android:theme="@style/LightTheme">
        <activity
            android:windowSoftInputMode="stateHidden"
            android:launchMode="singleTop"
            android:name=".main"
            android:label="Mio Dropbox"
            android:screenOrientation="unspecified">
            <intent-filter>
               <action android:name="android.intent.action.MAIN" />
               <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
           
        </activity>
        <service android:name=".starter">
        </service>
        <receiver android:name=".starter$starter_BR">
        </receiver>
    </application>
</manifest>

2) What should I write in place of db-xxx? In the instructions it is indicated to change db-xxx with db-yourappkey .. but what exactly would it be (db-yourappkey)? My email with which I am registered with DropBox?
Or what? Can you give me an example?
Thanks a lot for your help
 

DonManfred

Expert
Licensed User
Longtime User
2) What should I write in place of db-xxx? In the instructions it is indicated to change db-xxx with db-yourappkey .. but what exactly would it be (db-yourappkey)? My email with which I am registered with DropBox?
The APP KEY from the Dropbox Developer Console.
Edit your app and find the information there.


Note to edit the manifest so that you need to replace db-xxx with db-YOURAPPKEY.
for an App Key 123 it would be db-123
 
Last edited:
Upvote 0

Sabotto

Well-Known Member
Licensed User
I logged into Dropbox and clicked on "Create App"
I entered the name of the app (should I put the name of the package? ... and I wrote down the "app key" (an alphanumeric string of 15 characters of the type "55jhx49b ....."
I then replaced the "xxx" in the manifest file with this "app key" and I inserted the xml lines like this:
XML:
AddApplicationText(<activity
android:name="com.dropbox.core.android.AuthActivity"
android:configChanges="orientation|keyboard"
android:launchMode="singleTask" >
<intent-filter>
<data android:scheme="db-xxx" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>)

But I keep getting the error not in the code of the
B4X:
Sub btnStartOAuth_Click
auth.startOAuth2Authentication
End Sub

Error occurred online: 108 (Main)
java.lang.IllegalStateException: URI scheme in your app's manifest is not set up correctly. You should have a com.dropbox.core.android.AuthActivity with the scheme: db-xxx
at com.dropbox.core.android.AuthActivity.checkAppBeforeAuth (AuthActivity.java:287)
etc..

Among other things, by reopening the manifest file, I can no longer find the inserted lines !!!

I thought it was easier to be able to access a file of your Dropbox, perhaps by entering directly in the email code and password.?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upload a example project. LET YOUR APP KEY IN THE CORRECT PLACE.

You also DID adapted the Code in Main? Added your appkey there? Based on the error you are using "db-xxx" here!! Exactly like this; NO replacement for the XXX with your key "55jhx49b ....."

B4X:
    auth.Initialize("55jhx49b .....")
 
Last edited:
Upvote 0

Sabotto

Well-Known Member
Licensed User
I apologize.., I had missed this line of code
B4X:
auth.Initialize("55jhx49b .....")
where the appkey should be placed, I had only put it in the snippet of the xml file.
As soon as I get home I try.
But regarding the manifest file, in this post you say: "to prepare yor app to use the Auth-Activity from dropbox you need to add this snippet to your Manifest-Editor"
I ask: that snippet have to completely replace my manifest file or do I just have to add it?
And if I have to add it where do I have to insert it? After which line?
Or just add it to the end of my AndroidManifest.xml which is found in Objects?
Sorry if I ask you this but I am not expert and I never understood what exactly the manifest files are for. My fault!

However as soon as I am at home I try and if I still have errors I attach an example project
Thanks a lot for the help you are giving me
 
Upvote 0

Sabotto

Well-Known Member
Licensed User
So for safety I downloaded the sample project again.
In the Manifest file (DropboxV2 \ Objects \ AndroidManifest.xml) I replaced "db-xxx" with "db-55jhx49 ....."
XML:
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="b4a.VediTurno"
    android:versionCode="1"
    android:versionName=""
    android:installLocation="internalOnly">
    
    <uses-sdk android:minSdkVersion="5" android:targetSdkVersion="19"/>
    <supports-screens android:largeScreens="true"
        android:normalScreens="true"
        android:smallScreens="true"
        android:anyDensity="true"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
    <application
        android:icon="@drawable/icon"
        android:label="VediTurno">
        
        <activity
         android:name="com.dropbox.core.android.AuthActivity"
         android:configChanges="orientation|keyboard"
         android:launchMode="singleTask" >
        <intent-filter>
          <data android:scheme="db-55jhx4........" />
        <action android:name="android.intent.action.VIEW" />
          <category android:name="android.intent.category.BROWSABLE" />
          <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
        </activity>
        <activity
            android:windowSoftInputMode="stateHidden"
            android:launchMode="singleTop"
            android:name=".main"
            android:label="VediTurno"
            android:screenOrientation="unspecified">
            <intent-filter>
               <action android:name="android.intent.action.MAIN" />
               <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            
        </activity>
        <service android:name=".starter">
        </service>
        <receiver android:name=".starter$starter_BR">
        </receiver>
    </application>
</manifest>

In the code instead I only changed the follow two istructions
B4X:
#ApplicationLabel: VediTurno

B4X:
auth.Initialize("55jhx4.........")

But nothing: I always get this error, as soon as I tap the Auth button

Error occurred on line: 108 (Main)
java.lang.IllegalStateException: URI scheme in your app's manifest is not set up correctly. You should have a com.dropbox.core.android.AuthActivity with the scheme: db-55jhx4........

After, If I go to double check the manifest file, I find the line with
<data android:scheme="db-xxx" />
instead of
<data android:scheme="db-55jhx4........" />
It's normal? Maybe giving error puts the default line back in the Manifest file?
Can I post the project with my app key? In the following, however, ask for the password of my dropbox? I wouldn't want to get anyone into my dropbox.
 
Upvote 0

Sabotto

Well-Known Member
Licensed User
Hi, this morning, making the umpteenth test, I managed to connect to my DropBox. The only thing I did different was to edit the Manifest file directly from the IDE (Project - Editor Manifest menu) instead of with WordPad as I did before, because I did not know the existence of this tool (it has recently been " game "with B4A).
At the moment, therefore, I have solved at least the part of the communication.
Now I want to ask if it is possible to by-pass the insertion of the "unlock code" to access Dropbox and the confirmation where it says "The app would like to access the files and folders of your DropBox" and click on Allow, but for this I open a other thread. Thanks to all
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
1. You always should start a new Thread for a new Question.

This is how OAuth works.

If you just want Access YOUR Dropbox; not the one from the customer you can create a token in the appconsole and directly use this token in your app.
It is NOT recommended for apps you want to upload to the playstore as the token may be easily revealed and others do have access to your Dropbox.
But for your own apps it may fit your needs.
 
Upvote 0

Sabotto

Well-Known Member
Licensed User
Yes the app is for my personal use.
I start a new thread fo know how i can create a token directly in the code
 
Upvote 0
Top