Android Studio not installing App on device - java

SOLVED IT:
It was a problem of my Phone after resetting it everything worked.
Thanks to everybody that tried to help me.
I write a app in Android Studio and tested it on my device today I uninstalled it and tried to run it with Android Studio. But the app wont start and Android Studio generates the following error:
$ adb shell am start -n "de.clashbestie.pccontrol/de.clashbestie.pccontrol.activities.ConnectActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error while executing: am start -n "de.clashbestie.pccontrol/de.clashbestie.pccontrol.activities.ConnectActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=de.clashbestie.pccontrol/.activities.ConnectActivity }
Error type 3
Error: Activity class {de.clashbestie.pccontrol/de.clashbestie.pccontrol.activities.ConnectActivity} does not exist.
Error while Launching activity
And a screenshot too
Yes I see the "does not exist" and yeah this is the problem, the app gets not installed, but as seeable in the screenshot Android Studio say "Install succesfully finished".
I tried clean & rebuild restarted Android Studio, my PC, and My Device. Anybody knows what I can do else?
Btw. In emulator the app gets intalled.
Here is my mainfest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.clashbestie.pccontrol">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".activities.ControlActivity"
android:label="#string/title_activity_control"
android:theme="#style/AppTheme.NoActionBar"></activity>
<activity android:name=".activities.ConnectActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
ConnectActivity.java: (Removed Imports to short it)
package de.clashbestie.pccontrol.activities;
public class ConnectActivity extends AppCompatActivity {
private static ConnectActivity instance;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
instance = this;
}
public void connect(View v) {
findViewById(R.id.ip).clearFocus();
findViewById(R.id.port).clearFocus();
Button button = (Button) findViewById(R.id.connect);
if (button.getText().equals(getString(R.string.button_connecting))) {
Snackbar.make(instance.findViewById(R.id.connect), "Already connecting", Snackbar.LENGTH_SHORT).show();
} else {
button.setText(R.string.button_connecting);
String ip = ((EditText) findViewById(R.id.ip)).getText().toString();
String port = ((EditText) findViewById(R.id.port)).getText().toString();
((InputMethodManager) this.getSystemService(Activity.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(findViewById(R.id.connect).getWindowToken(), 0);
new ConnectorThread(ip, port).start();
}
}
public static void launchControlActivity(Socket socket) {
Button button = (Button) instance.findViewById(R.id.connect);
button.setText(R.string.button_connect);
try {
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
instance.getApplicationContext().startActivity(new Intent(instance, ControlActivity.class));
}
public static void showConnectError(String text) {
Button button = (Button) instance.findViewById(R.id.connect);
button.setText(R.string.button_connect);
Snackbar.make(instance.findViewById(R.id.connect), text, Snackbar.LENGTH_LONG).show();
}
}

The reason why you re getting the error is because you have no activity to launch the app , so in your manifest file , you should specify the launcher activity
This is the code
<activity
android:name=".activities.ControlActivity" activity
android:label="#string/title_activity_control"
android:theme="#style/AppTheme.NoActionBar"></activity>
<activity android:name=".activities.ConnectActivity"> // here specify the the
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Related

Error: Activity class {com.example.thejourney/com.example.thejourney.WelcomeActivity} does not exist

I'm trying to test an Android app I'm working on, I can see the app on the emulator but I get an error whenever I try to install it on the phone.
I've already tried all the methods listed on other similar posts but the solutions don't seem to work on my situation.
A big part of me tells me the problem is there's repetition in the activity name as in Error: Activity class {**com.example.thejourney/**com.example.thejourney.WelcomeActivity} does not exist. instead of com.example.thejourney.WelcomeActivity. If that's the case, I don't know where it's coming from, I've checked.
Welcome Activity
public class WelcomeActivity extends Activity {
public static int SPLASH_TIME_OUT = 5000;
LinearLayout l1,l2;
ImageView logo;
Animation uptodown,downtoup;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_welcome);
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
Intent mainIntent = new Intent(WelcomeActivity.this, MainActivity.class);
startActivity(mainIntent);
finish();
}
}, SPLASH_TIME_OUT);
logo = (ImageView) findViewById(R.id.logo);
l1 = (LinearLayout) findViewById(R.id.l1);
l2 = (LinearLayout) findViewById(R.id.l2);
uptodown = AnimationUtils.loadAnimation(this,R.anim.uptodown);
downtoup = AnimationUtils.loadAnimation(this,R.anim.downtoup);
l1.setAnimation(uptodown);
l2.setAnimation(downtoup);
}}
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.thejourney">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"
/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:usesCleartextTraffic="true">
<activity
android:name=".WelcomeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ProfileActivity"
android:parentActivityName=".MainActivity" />
<activity
android:name=".AboutActivity"
android:parentActivityName=".MainActivity" />
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main"
android:theme="#style/AppTheme.NoActionBar" />
<meta-data
android:name="preloaded_fonts"
android:resource="#array/preloaded_fonts" />
</application>
</manifest>
Your device might not work because developer mode and USB debugging might not be enabled. Try following the steps in https://developer.android.com/studio/run/device#setting-up.

android.content.ActivityNotFoundException: No Activity found to handle Intent

please help , when i run the app, the app launch a Fatal Error im learning
just i create a instat with a call but not run, (sorry for my english)
.......................................................................
my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.octa.appprueba3">
<uses-permission android:name="android.permission.CALL_PHONE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.APP_CONTACTS" />
</intent-filter>
</activity>
<activity android:name=".SecondActivity"></activity>
</application>
</manifest>
my code:
public class SecondActivity extends AppCompatActivity {
private EditText editPhoneText;
private ImageButton imageCallButton;
private final int PHONE_CALL_CODE = 100;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
editPhoneText = (EditText) findViewById(R.id.editTextPhone);
imageCallButton = (ImageButton) findViewById(R.id.imageCallButton1);
imageCallButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
implicito();
}
});
}
public void implicito(){
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("Tel: 9999999" ));
startActivity(intent);
}
}
You may want to check whether your device can handle your intent by doing this:
PackageManager packageManager = getPackageManager();
if (intent.resolveActivity(packageManager) != null) {
startActivity(intent);
} else {
Log.d(TAG, "Cannot handle this intent");
}
What's more, if you are placing a call like so, there is NO need to declare the permission in your manifest:
<uses-permission android:name="android.permission.CALL_PHONE" />
Because you are not directly calling someone within your app. You are actually transferring the "duty" to other apps which can handle your intent to call. This doesn't need a permission.
To directly make a call within your app, the intent should be Intent.ACTION_CALL, which needs the permission you declared.
Hope this will help.
There is no activity on your device that handles ACTION_DIAL for a Tel: scheme. Try:
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:9999999" ));
Case and whitespace are important when assembling a Uri.
Also note that even my revised Intent will not work on all devices, such as on an Android tablet that lacks a dialer.

Start an Android app from a Broadcast

I'm new to the Android API and i try hard to start my app (NOT an Activity) from a Broadcast receiver. It's compiling and manualy launching on my Device, but not automatically launching when i plug an USB device in.
My goal : plug usb in -> start app -> "Hello World!"
===============================[edit]======================================
That's the final version that is working for me. If it's not working for you test with an other device.
Works on my Moto G 1st Gen. Android 5.1.1.
Do not work on my S3 I9300 Android 4.4.4
tests :
Reboot -> OS running -> plug USB in -> unlock the screen -> "Hello world"
Unlock -> plug in -> "Hello world"
...
The code :
package com.example.desktop.helloworld;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
public class HelloworldActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_helloworld);
TextView tv = new TextView(this);
tv.setText("Hello World!");
setContentView(tv);
}
public static class BootUpReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent(context, HelloworldActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
}
The Manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.desktop.helloworld">
<uses-feature android:name="android.hardware.usb.host" />
<uses-permission android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".HelloworldActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:enabled="true" android:name=".HelloworldActivity$BootUpReceiver">
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="#xml/device_filter" />
</receiver>
</application>
device_filter (NOT REQUIERED, then comment the reffence in the manifest):
<?xml version="1.0" encoding="utf-8"?>
<resources>
<usb-device vendor-id="0403" product-id="6001"/>
</resources>
Android Studio 2.0,
OTG Cable,
Android 4.4.4 .

Nothing to show when sharing a picture using facebook sdk android

I'm trying to learn how to share a simple image using android and facebook SDK following this tutorial.
I already configured the app in the facebook developers page, that includes the App ID, the development key hash and the release key hash.
The problem is, when I login it appears this screen:
and then when I click OK nothing happens ...
Here's my MainActivity:
public class MainActivity extends ActionBarActivity {
private CallbackManager callbackManager;
private LoginManager loginManager;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Get the release key hash in Debug.Log
generateHash();
// Initialize the facebook SDK
FacebookSdk.sdkInitialize(getApplicationContext());
callbackManager = CallbackManager.Factory.create();
// If we want to publish something on facebook we need publish permission
List<String> permissionNeeds = Arrays.asList("publish_actions");
loginManager = LoginManager.getInstance();
loginManager.logInWithPublishPermissions(this, permissionNeeds);
loginManager.registerCallback(callbackManager, new FacebookCallback<LoginResult>()
{
#Override
public void onSuccess(LoginResult loginResult)
{
sharePhotoToFacebook();
}
#Override
public void onCancel()
{
System.out.println("onCancel");
}
#Override
public void onError(FacebookException exception)
{
System.out.println("onError");
}
});
}
private void sharePhotoToFacebook(){
Bitmap image = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(image)
.setCaption("Give me my codez or I will ... you know, do that thing you don't like!")
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
ShareApi.share(content, null);
}
And heres my AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.FacebookActivity"
android:theme="#android:style/Theme.Translucent.NoTitleBar"
android:label="#string/app_name"/>
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/app_id"/>
<provider
android:authorities="com.facebook.app.FacebookContentProvider1018821948180724"
android:name="com.facebook.FacebookContentProvider"
android:exported="true">
</provider>
</application>
Any tips on what am I doing wrong?
Thanks in advance.
Have you added Facebook ContentProvider to your manifest?
<provider android:authorities="com.facebook.app.FacebookContentProvider{APP_ID}"
android:name="com.facebook.FacebookContentProvider"
android:exported="true"/>
And remember these things :
1. The photos must be less than 12MB in size
2. You need to ask publish_actions permission when logging in

Cannot create folder in SD card on Android

I have this problem in my application. I want to create a folder in Emulator SD card but it didn't work and I don't know why. I tried mkdir and mkdirs.
I added WRITE_EXTERNAL_STORAGE Permission to the Manifest. I tried with MediaScannerConnection and didn't work. I've searched a lot the web and tried a lot of implementations but no change. What could be the issue?
Here is my code:
public void createDirIfNotExists() {
File folder = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/cdp");
boolean success = true;
if (!folder.exists()) {
success = folder.mkdirs();
}
if (success) {
Log.e("Folder: ", "folder created!!");
} else {
Log.e("Folder Error: ", "folder cannot be created!!");
}
}
My manifest look like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.aboussof.myapplication" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
</activity>
<activity android:name=".Test">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
And so I try to create the folder:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mProgressDialog = new ProgressDialog(Test.this);
mProgressDialog.setMessage("A message");
mProgressDialog.setIndeterminate(true);
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mProgressDialog.setCancelable(true);
// execute this when the downloader must be fired
final DownloadTask downloadTask = new DownloadTask(Test.this);
createDirIfNotExists();
downloadTask.execute("http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_5mb.mp4");
mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
#Override
public void onCancel(DialogInterface dialog) {
downloadTask.cancel(true);
}
});
}
Replace
File folder = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/cdp");
with
File folder = new File(Environment.getExternalStorageDirectory() + "/", "cdp");
Have you solved your issue yet?
I use your method with a tiny change at
File folder = new File(Environment.getExternalStorageDirectory(), "cdp");
And the result like the following screenshot:
My AVD configuration like the following:
I have had the same issue - file.mkdirs() returns false on android emulator API 23. And all configs was set according to BNK's answer.
Try to change API to 19 - it works for me. Looks like weird emulator/android version issue.

Categories

Resources