0

Well - it would seem over the past several days, I've read almost every threat here about the subject, but none have worked!

I've just started to develop a new app and as soon as the project was created, the error appear.

As a last resort only, could some kinda fellow (or gal :) ) kindly observe to see if they can spot an issue which may be hindering my applications function?

MainApplication.java;

 package com.sony.thirdtest;

import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.view.View;
import android.widget.Toast;
import com.sony.smallapp.SmallAppWindow;
import com.sony.smallapp.SmallApplication;

public class MainApplication extends SmallApplication {
private Configuration mConfig;

@Override
public void onCreate() {
    super.onCreate();
    mConfig = new Configuration(getResources().getConfiguration());

    setContentView(R.layout.activity_main);
    setTitle(R.string.app_name);

    SmallAppWindow.Attributes attr = getWindow().getAttributes();
    attr.minWidth = 200;
    attr.minHeight = 200;
    attr.width = 400;
    attr.height = 300;
    attr.flags |= SmallAppWindow.Attributes.FLAG_RESIZABLE;
    getWindow().setAttributes(attr);

    findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(MainApplication.this, R.string.hello, Toast.LENGTH_SHORT).show();
        }
    });
}

@Override
public void onDestroy() {
    super.onDestroy();
}

@Override
public void onStart() {
    super.onStart();
}

@Override
public void onStop() {
    super.onStop();
}

@Override
protected boolean onSmallAppConfigurationChanged(Configuration newConfig) {
    int diff = newConfig.diff(mConfig);
    mConfig = new Configuration(getResources().getConfiguration());
    // Avoid application from restarting when orientation changed
    if ((diff & ActivityInfo.CONFIG_ORIENTATION) != 0) {
        return true;
    }
    return super.onSmallAppConfigurationChanged(newConfig);
}

}

main_activity.xml;

<manifest  
package="com.sony.thirdtest" 
android:versionCode="1" 
android:versionName="1.0"
xmlns:android="http://schemas.android.com/apk/res/android" >

<uses-sdk android:minSdkVersion="14"
          android:targetSdkVersion="15" />

<uses-permission android:name="com.sony.smallapp.permission.SMALLAPP" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >   


    <uses-library android:name="com.sony.smallapp.framework" />

    <service 
        android:name="MainApplication"

        android:exported="true" >

        <intent-filter >

            <action android:name="com.sony.smallapp.intent.action.MAIN" />

            <category android:name="com.sony.smallapp.intent.category.LAUNCHER" />

        </intent-filter>

    </service>

</application>

Can I please make clear that this has been a last resort,

Kind regards.

James
  • 65,548
  • 14
  • 155
  • 193
UKPixie
  • 151
  • 1
  • 2
  • 7
  • 1
    is there any errors in your resource files. cross check once? did this happen after updating adt to rev 22? – Raghunandan May 23 '13 at 15:43
  • I'm running the latest version of ADT, so I would assume so. The only files I have in the recourse folders are ic_launcher.png - in the drawable folders. No other errors in the program. Just these 2 about "R" – UKPixie May 23 '13 at 15:50
  • http://stackoverflow.com/questions/16636039/java-lang-classnotfoundexception-after-changing-nothing-in-the-project-but-upgra/16636127#16636127. try this. if it crashes i suggest you post logcat info of the crash – Raghunandan May 23 '13 at 15:50
  • //missing a . Also are you sure you want a service instead of activity?. http://developer.android.com/guide/components/services.html – Raghunandan May 23 '13 at 15:54
  • Import com.sony.thirdtest.R; – Yauraw Gadav May 23 '13 at 17:27

3 Answers3

0

This is were the error might be. findViewById(R.id.button).setOnClickListener(new View.OnClickListener()

declare button this way and try

            public class MainApplication extends SmallApplication {
             private Configuration mConfig;
             Button button1;

                  @Override
                 public void onCreate() {
                button1 = (Button) findViewById(R.id.button1);
                  button1.setOnClickListener(new OnClickListener()
                      {
                         Toast.makeText(getBaseContext(), 
                    "your message", 
                    Toast.LENGTH_SHORT).show();
                    }
                 }
Metalhead1247
  • 1,978
  • 1
  • 17
  • 28
0

It missing manifest balise at end file. And it is better to put xmlns attribut at first. Try this:

<manifest  
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.sony.thirdtest" 
    android:versionCode="1" 
    android:versionName="1.0"
     >

    <uses-sdk android:minSdkVersion="14"
              android:targetSdkVersion="15" />

    <uses-permission android:name="com.sony.smallapp.permission.SMALLAPP" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >   


        <uses-library android:name="com.sony.smallapp.framework" />

        <service 
            android:name="MainApplication"

            android:exported="true" >

            <intent-filter >

                <action android:name="com.sony.smallapp.intent.action.MAIN" />

                <category android:name="com.sony.smallapp.intent.category.LAUNCHER" />

            </intent-filter>

        </service>

    </application>
    </manifest>
Jarvis
  • 1,527
  • 12
  • 17
0

It is late but i'm facing with that problem too many times and i want to share my opinion. The problem is about your resource files. Check your layouts, values etc. Adt will always say that import android.R or import com.yourpackage.R. Do not regard that quick fixes.

Batuhan Coşkun
  • 2,961
  • 2
  • 31
  • 48