Android App Error unknownpackageerror - android

I am creating simple android application in android of hello world printing and getting an -- error Description
Resource Path Location Type Error generating final archive: java.lang.ArrayIndexOutOfBoundsException: 13 Demo_ABC Unknown Android Packaging Problem
Code is:
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity
{
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}

Someone else had the same problem with eclipse. The solution was to check the box "Create Test Project":
Your project is getting associated with some Test Project which you are not mapping with your newly created project. When you are creating any new project check carefully whether you are including the "Create Test Project" option or not.
Another guess: As the error seems to be package-related and your code does not include that, insert the correct package yourpackage.tld; in the code. (you said "Code is:").
Maybe that is missing Android expects it by default and gives weird errors because that was totally unforseen by the Google Android developers.

Related

setContentView(R.layout.main); - cannot find package

I have never used Android Studio before and have always been coding using NetBeans.
I need to create an app for Android, so I decided to use NetBeans. I created new project and it is 'empty' for now, however I have an error:
package Fridge.Freezer;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity
{
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
The error is in setContentView(R.layout.main); - cannot find package. Can anyone tell what I am doing wrong? Clean and build does not work.
erase your package name at the top and try to add it to getting the suggestion package import by shortcut Control + Enter beside "R"
Try checking following component in your project directory
R.java file
folder named layout
layout xml file named main.xmlmain
PS Since your are starting a fresh project, I would suggest you to start at Android Studio.
I tried cleaning the project and rebuilding it again. It did not work. The solution was to restart IDE.

Missing R.java on Linux Eclipse Android project

I am running Eclipse Indigo with Android SDK 4.0.3 and Google API in Linux 11.10. However, when I start up a new Android project, my R.java is no where to be found, hence resulting in the following issue:
package com.lol.asdf;
import android.app.Activity;
import android.os.Bundle;
public class AsdfActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
I have tried all suggestion on this page but it's no good.
Anyone have any ideas?
your R.java is an auto generated class from the res/ folder. Check for error inside it. Try clean and rebuild your project too.
R.java will generated automatically...
first solve all other errors of your project it will be created...

How to fix NoClassFoundError in android

I have two classes in a different projects.
I am importing the project that has the class that I need.
Now, I have no errors.
The project know's that class and I even made an object from that class, but when I'm trying to run it it crushes with the "NoClassFoundError".
How can i fix that?
import com.dmg.pixelservice.core.*;
import android.app.Activity;
import android.os.Bundle;
public class show extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Pixel pixel = new Pixel();
pixel.doIt(this,"fd7ccf36-3f85-11e1-8671-40409e0f44a1",true);
setContentView(R.layout.main);
}
}
When I debug, I can see that it crashes when I'm trying to do Pixel pixel = new Pixel();
Please help.
create new libs folder in your application .name must be same.and put your jar files in this folder.and
go to
java Build Path -> Configure Build Path -> Add jars
Looks like the jar file containing the Pixel class is not packaged into the APK.
To make that happen, it seems you need to copy the jar into the libs folder of your Android project.
See this question:
Approach for fixing NoClassDefFoundError?
Android Developer Guide:
http://developer.android.com/guide/developing/projects
it is easy to find the error if you send the src code of your Pixel class.

"emulator: ERROR: no search paths found in this AVD's configuration" Android Activity issue

When I try to run the Hello, Android Activity, it says: emulator: ERROR: no search paths found in this AVD's configuration.
And underneath that it says: Weird, the AVD's config.ini file is malformed. Try re-creating it.
I'm stumped and would really appreciate if someone could help me out.
This is what I have for the code:
package my.helloandroid.activity;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloAndroidActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
}
}
Check the manifest file or look here:
Trouble getting Android emulator to run in eclipse
Three things which came to my mind.
Be sure to check if you have correct path to avd, Window->preferences.
Press right mouse button on your project folder and use android tools -> fix project.
simply restart eclipse.

Android: Can't get logs with SLF4J-Android

I'm building a really simple Android project in ADT and using Maven. I have included both the slf4j-api and slf4j-android dependencies and I can see that everything is compiling properly. However, when I run or debug the application on my Nexus One, I don't see any log output. Is there a specific place I should be looking for these logs or should they be coming out in the Eclipse console?
For reference, here's my main activity:
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import android.app.ListActivity;
import android.os.Bundle;
public class HomeActivity extends ListActivity {
private static Logger logger = LoggerFactory.getLogger(HomeActivity.class);
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
logger.debug("onCreate");
}
}
Android by default tells slf4j-android to not to log debug messages, and log4j is polite enough to honor that. Use the impolite https://github.com/mvysny/slf4j-handroid instead :)
I use slf4j as well for logging. The log output shows up on the LogCat window. I'm not sure if there's a way to see it in the Eclipse console. In the Eclipse top-level menu, navigate to: Window -> Show View -> Other. When the dialog appears, expand "Android", and select "LogCat". It doesn't show up by default, unfortunately.
HTH,
Kevin
You may want to have a look at using slf4j together with android-logging-log4j. Also see log4j support in Android.

Categories

Resources