2017-04-14 6 views
0

この問題を解決するのに手伝ってくれる人。 (NoSuchMethodError)私は本当にこのエラーを理解していません。私の最初のアプリ、Google Playストアでこれを表示する

私はウェブ上で同様の問題を発見しましたが、掲載されたソリューションのどれも動作していないようです。私を助けることができる人。 編集:私はすでにAndroid Studioで作業しています。 My screenshot Other

package com.example.android.xxxxxxxxxxy; 
    import android.content.Intent; 
    import android.content.res.Configuration; 
    import android.media.MediaPlayer; 
    import android.net.Uri; 
    import android.support.v4.widget.DrawerLayout; 
    import android.support.v7.app.ActionBarDrawerToggle; 
    import android.support.v7.app.AppCompatActivity; 
    import android.os.Bundle; 
    import android.view.Menu; 
    import android.view.MenuItem; 
    import android.view.View; 
    import android.widget.AdapterView; 
    import android.widget.ArrayAdapter; 
    import android.widget.Button; 
    import android.widget.ListView; 
    import android.widget.Toast; 
    import com.google.android.gms.ads.AdRequest; 
    import com.google.android.gms.ads.AdView; 

public class MainActivity extends AppCompatActivity { 

private ListView mDrawerList; 
private DrawerLayout mDrawerLayout; 
private ArrayAdapter<String> mAdapter; 
private ActionBarDrawerToggle mDrawerToggle; 
private String mActivityTitle; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    mDrawerList = (ListView)findViewById(R.id.navList);mDrawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout); 
    mActivityTitle = getTitle().toString(); 

    addDrawerItems(); 
    setupDrawer(); 

    getSupportActionBar().setDisplayHomeAsUpEnabled(true); 
    getSupportActionBar().setHomeButtonEnabled(true); 



    AdView adView = (AdView) findViewById(R.id.adView); 

    AdRequest adRequest = new AdRequest.Builder() 
      .setRequestAgent("android_studio:ad_template").build(); 

      // The firstbutton (song). 

    assert adView != null; 
    adView.loadAd(adRequest); 

    final MediaPlayer happy_birthday_to_me = MediaPlayer.create(this, R.raw.happy_birthday_to_me); 

    Button playsongmeow = (Button) this.findViewById(R.id.play_song_meow); 

    assert playsongmeow != null; 
    playsongmeow.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      happy_birthday_to_me.start(); 

     } 
    }); 

      // The secondbutton (song). 

    assert adView != null; 
    adView.loadAd(adRequest); 

    final MediaPlayer birthday = MediaPlayer.create(this, R.raw.birthday); 

    Button playsongmeoww = (Button) this.findViewById(R.id.play_song_meoww); 

    assert playsongmeoww != null; 
    playsongmeoww.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      birthday.start(); 

     } 
    }); 


      // The thirdbutton (song). 

    assert adView != null; 
    adView.loadAd(adRequest); 

    final MediaPlayer happy = MediaPlayer.create(this, R.raw.happy); 

    Button playsongmeowww = (Button) this.findViewById(R.id.play_song_meowww); 

    assert playsongmeowww != null; 
    playsongmeowww.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      happy.start(); 

     } 
    }); 


      // The fourthbutton (song). 

    assert adView != null; 
    adView.loadAd(adRequest); 

    final MediaPlayer original = MediaPlayer.create(this, R.raw.original); 

    Button playsongmeowwww = (Button) this.findViewById(R.id.play_song_meowwww); 

    assert playsongmeowwww != null; 
    playsongmeowwww.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      original.start(); 

     } 
    }); 

} 

private void addDrawerItems() { 
    String[] osArray = {"Songs", "Photos", "Videos", "About"}; 
    mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, osArray); 
    mDrawerList.setAdapter(mAdapter); 

    mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
     @Override 
     public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 
      Intent intent = new Intent(MainActivity.this, MainActivity.class); 
      startActivity(intent); 

      switch (position) { 
       case 0: //Log History 
        Intent MainActivity = new Intent(MainActivity.this, MainActivity.class); 
        startActivity(MainActivity); 
        break; 
       case 1: //Log History 
        Intent Photos = new Intent(MainActivity.this, Photos.class); 
        startActivity(Photos); 
        break; 
       case 2: //Log History 
        Intent Videos = new Intent(MainActivity.this, Videos.class); 
        startActivity(Videos); 
        break; 
       case 3: //Log History 
        Intent About = new Intent(MainActivity.this, About.class); 
        startActivity(About); 
       default: 
      } 
     } 
    }); 
} 

private void setupDrawer() { 
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) { 

     /** Called when a drawer has settled in a completely open state. */ 

     public void onDrawerOpened(View drawerView) { 
      super.onDrawerOpened(drawerView); 
      getSupportActionBar().setTitle("List Menu"); 
      invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() 
     } 

     /** Called when a drawer has settled in a completely closed state. */ 

     public void onDrawerClosed(View view) { 
      super.onDrawerClosed(view); 
      getSupportActionBar().setTitle(mActivityTitle); 
      invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() 
     } 
    }; 

    mDrawerToggle.setDrawerIndicatorEnabled(true); 
    mDrawerLayout.setDrawerListener(mDrawerToggle); 
} 

@Override 
protected void onPostCreate(Bundle savedInstanceState) { 
    super.onPostCreate(savedInstanceState); 

    // Sync the toggle state after onRestoreInstanceState has occurred. 

    mDrawerToggle.syncState(); 
} 

@Override 
public void onConfigurationChanged(Configuration newConfig) { 
    super.onConfigurationChanged(newConfig); 
    mDrawerToggle.onConfigurationChanged(newConfig); 
} 

@Override 
public boolean onCreateOptionsMenu(Menu menu) { 

      // Inflate the menu; this adds items to the action bar if it is present. 

      getMenuInflater().inflate(R.menu.menu_main, menu); 
      return true; 
} 

@Override 
public boolean onOptionsItemSelected (MenuItem item) { 

      // Inflate your main_menu into the menu. 

      int id = item.getItemId(); 

    switch (id){ 
     case R.id.about: 


      Intent About = new Intent(MainActivity.this, About.class); 
      startActivity(About); 

      break; 
    } 

    switch (id) { 
     case R.id.rate: 

      // Open this Uri. 

      Uri uri = Uri.parse("https://play.google.com/store/apps/details?id=com.exafmpflle.android.happybirthdayyyy&hl=en"); // missing 'http://' will cause crashed 
      Intent intent = new Intent(Intent.ACTION_VIEW, uri); 
      startActivity(intent); 

      break; 
    } 

    switch (id){ 
     case R.id.privacy: 

      // Open this Uri. 

      Uri uri = Uri.parse("https://docs.google.com/document/d/1DEBh3j3LG5WaF9nT9Gl2hpswa3yD-36MfPhVo3S_p08/edit"); // missing 'http://' will cause crashed 
      Intent intent = new Intent(Intent.ACTION_VIEW, uri); 
      startActivity(intent); 

      break; 
    } 

    // Activate the navigation drawer toggle 

    if (mDrawerToggle.onOptionsItemSelected(item)) { 
     return true; 
    } 

    return super.onOptionsItemSelected(item); 
} 

} 

答えて

0

エラーは、オーバーライドされている方法の一つが存在しないと言っているように見えます。上書きしているメソッドのスペルを二重チェックしてみてください。

これが役立つ場合は、この投稿を回答としてマークしてください。

関連する問題