2013-05-23 9 views
0

글쎄, 지난 며칠 동안 보였을 것입니다. 주제에 관한 거의 모든 위협을 읽었지만 아무도 효과가 없었습니다!R을 해결할 수 없습니다 (또 다른)

방금 ​​새 앱을 개발하기 시작했으며 프로젝트를 만든 즉시 오류가 표시됩니다.

최후의 수단으로 만 동료 (또는 gal :))가 내 응용 프로그램 기능을 방해 할 수있는 문제를 발견 할 수 있는지 여부를 친절하게 관찰 할 수 있습니까?

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> 

나는,이 최후의 수단되었다는

종류의 안부를 명확하게 주시겠습니까.

+1

리소스 파일에 오류가 있습니다. 한 번 교차 확인 하시겠습니까? 이것이 rev 22로 adt를 업데이트 한 후에 발생 했습니까? – Raghunandan

+0

최신 버전의 ADT를 실행 중이므로 그렇게 할 것입니다. 나는 recourse 폴더에있는 유일한 파일은 drawable 폴더에있는 ic_launcher.png입니다. 프로그램에있는 다른 오류는 없습니다. 이 두 가지만 "R" – UKPixie

+0

http://stackoverflow.com/questions/16636039/java-lang-classnotfoundexception-after-changing-nothing-in-the-project-but-upgra/16636127#16636127. 이 시도. 충돌이 발생하면 logcat 정보를 게시 하시길 바랍니다. – Raghunandan

답변

0

이것은 오류 일 수 있습니다. findViewById를 (R.id.button) .setOnClickListener (새 View.OnClickListener()

선언 버튼이 방법과 최종 파일에 매니페스트 발리 누락

  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(); 
        } 
       } 
0

보십시오. 그리고 그것은 더 나은의 xmlns가 attribut 넣어 .

<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> 
0

늦었하지만 난 너무 많은 시간이 문제에 직면하고있어 난 내 의견을 공유 할 문제는 리소스 파일에 관한 확인하여 레이아웃, 값 등 : 처음에이보십시오.. Adt는 항상 import android.R 또는 import com.yourpackage.R이라고합니다. Do n 그 빠른 수정을 생각해라.

관련 문제