Android exception unknown source

Why do my Android app get an Unknown Source Exception requesting short-lived authorization code in Google OAuth 2.0 flow?

We have a project consisting of an android app and a web back-end, and as such it is registered in the Google Console. The Android app is authenticating the user with his Google account (Google OAuth 2.0 flow).

We are successful in getting an access token to access the Google APIs. (the scope is: «oauth2: «+SCOPE_PLUS_LOGIN+» «+SCOPE_EMAIL+» «+SCOPE_PROFILE)

We are successful in getting an id token, that the app can forward to the back-end, as well. (the scope is: «audience:server:client_id:»+SERVER_CLIENT_ID)

The problem is when we ask for a short-lived authorization code (needed for the offline access of the back-end) we get an GoogleAuthException: Unknown at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source).

We know two things:

The scope is ok, because we tested the permissions and the web_client_id already in the case of access token and id token. Scope is: «oauth2:server:client_id:»+»SERVER_CLIENT_ID»+»:api_scope:»+SCOPE_PLUS_LOGIN and the syntax is as described here: https://developers.google.com/accounts/docs/CrossClientAuth in part for obtaining an offline access for the back-end.

The source code is ok, because it this the same source code as in the access token and id token case (where it works perfectly), only the scope is different. Code is taken from here: http://developer.android.com/google/auth/http-auth.html#ExtendAsyncTask

What can be the reason the short-lived authorization code won’t be returned although the two other are? In some other questions here somebody suggested that getting the short-lived authorization code stopped working for them too. Can it be that it isn’t available anymore or that sth in the specifications changed lately?

Источник

com.google.android.gms.auth.GoogleAuthException: getToken(Unknown Source) exception

In my Android application, I am trying to get google token to verify at my google app engine backend server. But I always get this exception :

I have tried every solution proposed in Stackoverflow.

3 Answers 3

After several hours, I found that in your scope string ( «audience:server:client_id. » ) you have to use the Client ID of the web application, not the android one.

The client ID of the android app is unused. It’s only here to link the package name of your android app with your web app.

After 2 days of research I found that at the time you register your android application in Google Cloud Console -> your project — > API and auth, it ask you for fingerprint in order to generate ClientID and somehow my fingerprint was wrong (I accidentally added

Читайте также:  Где лежат сохранения atom rpg android

$ before this cmd keytool -exportcert -alias androiddebugkey -keystore

/.android/debug.keystore | openssl sha1 ) and due to this it was giving me wrong finger print and was the root cause of:

After reading couple of posts on the internet I generated SHA1 fingerprint value of my keystore as

keytool -exportcert -alias android_keystore -keystore android_keystore -list -v | openssl sha1

due to which I was getting that error. If you see the credentials screen in you google developer console it says you need to use

keytool -exportcert -alias android_keystore -keystore android_keystore -list -v

i.e Don’t pipe the output to openssl sha1. Not sure what the difference is but both commands give different values.

You will get multiple fingerprints like MD5, SHA1, SHA256 etc. Use SHA1 value.

Источник

«unknown source» error when trying to run app from Android studio

When installing new application from Android studio, the phone cancels the installation showing a notification that it’s from unknown sources.

How can I authorize Android Studio app install on my device?

Notice: the device used is vivo y97 (Funtouch OS_9) connected to android studio using USB cable.

1 Answer 1

for running on real device you should follow these steps first:

Run Android App on Real device

You need to follow these steps to make your Android Device ready so that you can test your App.

Enable Developer Option Enable USB Debugging Install USB Drivers Connect the Device to Computer Enabling Developer Option

To Enable USB Debugging, First, we need to enable Developer Option on the phone. Google since Android Version 4.2 has disabled the Developer Option. This was done so that people do not enable the USB Debugging Mode accidentally. Enabling USB Debugging Mode puts your device into the security risk.

For the devices with Android Version lower than 4.,2 the developer Option is already enabled.

To Enable the Developer Option to follow the steps

Go to settings and tap on About Phone / About Device or About Tablet Option

Tap on Software Info Option

Locate Build Number and Tap on it seven times. You will see the message “You are now a developer” message. If the developer mode is already enabled then you will see the message “No need, developer mode has already been enabled”

Читайте также:  Сброс графического пароля android без потери данных

Disable Developer option

In case you wish to disable the developer option you can go to Settings -> Application Manager. Select the Settings App. Select the Storage Option and clear the data. Note this will also reset your preferences within the settings menu.

Enable USB debugging

To enable USB Debugging, follow these steps

Go to Settings Go to Developer Options Goto USB Debugging Option and enable it

Disable Developer option

In case you wish to disable the developer option you can go to Settings -> Application Manager. Select the Settings App. Select the Storage Option and clear the data. Note this will also reset your preferences within the settings menu.

Enable USB debugging

To enable USB Debugging, follow these steps

Go to Settings Go to Developer Options Goto USB Debugging Option and enable it Connecting Over Wi-Fi

Connect your device on the same wifi network as that of PC

Find out the IP Address of the Device. There are two ways you can find out the IP address.

Goto settings -> About Device Tap on Status. Or

Goto settings -> Wi-Fi Tap on the Wifi Network connected Locate the adb.exe. The adb is known as Android Debug Bridge is the tool that lets us communicate with a device. This tool is located under the platform-tools folder under the Android SDK folder.

The Android SDK folder can be found out by type SET ANDROID_HOME command. goto the folder The adb is already running and listening on the USB port for the devices. To make it to listen to the TCP/IP Port number 5555 run the following command

Now, to connect the device run the following command

Replace the IP 192.168.0.103 with the IP Address of your device.

To disable TCP/IP and enable the USB, run the command

Источник

(Unknown Source) in Exception stack trace

Background

Consider the following snippet:

As explained in the answer to the linked question, Java’s method overloading resolves the above invokation to String.valueOf(char[]) , which rightfully results in a NullPointerException at run-time.

Compiled in Eclipse and javac 1.6.0_17 , this is the stack trace:

Note that the stack trace above is missing the KEY information: it does NOT have the full signature of the valueOf method! It just says String.valueOf(Unknown Source) !

In most situations I’ve encountered, exception stack traces always have the complete signature of the methods that are actually in the stack trace, which of course is very helpful in identifying the problem immediately and a major reason why the stack trace (which needless to say is rather expensive to construct) is provided in the first place.

Читайте также:  Телевизор xiaomi mi4 32 android tv

And yet, in this case, the stack trace does not help at all. It has failed miserably in helping the programmer identify the problem.

As is, I can see 3 ways that a programmer can identify the problem with the above snippet:

  • Programmer realizes on his/her own that the method is overloaded, and by resolution rule, the «wrong» overload gets invoked in this case
  • Programmer uses a good IDE that allows him/her to quickly see which method is selected
    • In Eclipse, for example, mouse-hovering on the above expression quickly tells programmer that the String valueOf(char[] data) is indeed the one selected
  • Programmer examines the bytecode (ugh!)

The last option is probably the least accessible, but of course is the Ultimate Answer (a programmer may misunderstood the overloading rule, IDE may be buggy, but bytecodes always(?) tell the truth on what’s being done).

Источник

How to fix Unknown sources error during App install?

Created an App in android studio. While try to install it in real device. I am getting an error «For Security, your phone is set to block installation of apps obtained from Unknown sources.»

I removed this error by going to setting and enabled install from Unknown sources. After that app get installed.

Question:
1) How can i make this app as trusted known source for installation without making Unknown sources option enabled.

Even i tried to create a signed APK in android studio. But Still real device is reporting as Unknown sources.

Can someone help me to make App as trusted known source?

1 Answer 1

All apps outside of Google Play Store will get the Unknown Source Error.

You must upload your apk file to your google play developer console and user must download your app via Google Play. Otherwise user should enable the Unknown Sources checkbox from the settings in order to install the app.

When you sign your application, you will prevent from tampering the original source and when the attacker tampered your application and signed it with his key OS will alert the user to uninstall the app and install the fresh version to prevent data hijacking. But this still doesn’t make the app as trusted app.

Hence all the apps, signed or unsigned, outside the Google Play Store are considered as app from unknown source.

Источник

Оцените статью