2

我的第一个问题,所以我希望我做对了。

我在我的 Android 项目中添加了平板电脑布局,现在我在各种设备上都有一些崩溃报告。它对我来说 100% 正常工作,但是,使用平板电脑的测试人员在运行时会被强制关闭。

该应用程序是一个简单的仪表板,允许用户将主题应用到第三方启动器,就像 Stark 和 Flatro 图​​标包一样。

这是错误:

java.lang.NoClassDefFoundError: com.arandompackage.jive.Fragment1$1
at com.arandompackage.jive.Fragment1.onActivityCreated(Fragment1.java:57)
at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1468)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:931)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:461)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1064)
at android.support.v4.view.ViewPager.populate(ViewPager.java:911)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1432)
at android.view.View.measure(View.java:12911)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:828)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:557)
at android.view.View.measure(View.java:12911)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4805)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:297)
at android.view.View.measure(View.java:12911)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:828)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:557)
at android.view.View.measure(View.java:12911)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4805)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:297)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2097)
at android.view.View.measure(View.java:12911)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1064)
at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4441)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)
at dalvik.system.NativeStart.main(Native Method)

java.lang.RuntimeException: Unable to instantiate receiver com.arandompackage.jive.AnalogClockWidget: java.lang.ClassNotFoundException: com.arandompackage.jive.AnalogClockWidget
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2261)
at android.app.ActivityThread.access$1600(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1313)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4946)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1036)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:803)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.arandompackage.jive.AnalogClockWidget
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2256)
... 10 more

我已经完成了所有这些帖子所建议的一切,但无济于事。

这是fragment1 java

package com.arandompackage.jive;

import com.arandompackage.jive.R;

import de.keyboardsurfer.android.widget.crouton.Crouton;
import de.keyboardsurfer.android.widget.crouton.Style;
import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;


public class Fragment1 extends Fragment{

    static final String ACTION_APPLY_ICON_THEME = "com.teslacoilsw.launcher.APPLY_ICON_THEME";
      public static final String ACTION_MYTHEME = "com.gau.go.launcherex.MyThemes.mythemeaction";
      public static final String ACTION_SET_THEME = "com.anddoes.launcher.SET_THEME";
      static final String EXTRA_ICON_THEME_PACKAGE = "com.teslacoilsw.launcher.extra.ICON_THEME_PACKAGE";
      static final String EXTRA_ICON_THEME_TYPE = "com.teslacoilsw.launcher.extra.ICON_THEME_TYPE";
      public static final String EXTRA_PACKAGE_NAME = "com.anddoes.launcher.THEME_PACKAGE_NAME";

    ImageButton button;
    Button button2;



    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
        return inflater.inflate(R.layout.fragment_1, null);

    }
    private boolean isAppInstalled(String uri) {
        PackageManager pm = getActivity().getPackageManager();
        boolean installed = false;
        try {
           pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
           installed = true;
        } catch (PackageManager.NameNotFoundException e) {
           installed = false;
        }
        return installed;
    }

    @Override
    public void onActivityCreated (Bundle savedInstanceState)
    {
    super.onActivityCreated(savedInstanceState);

    button = (ImageButton) getActivity().findViewById(R.id.apextheme);
    button.setOnClickListener(new View.OnClickListener() {



    @Override
    public void onClick(View v) {

        if (isAppInstalled("com.anddoes.launcher")) {
                      Intent intent3 = new Intent("com.anddoes.launcher.SET_THEME");
                      intent3.putExtra("com.anddoes.launcher.THEME_PACKAGE_NAME", getActivity().getPackageName());
                      startActivity(intent3);
                      Crouton.makeText(getActivity(), "TAP APPLY TO FINALIZE", Style.INFO, (ViewGroup) getView()).show();
   } else { 
    AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    alert.setTitle(R.string.apexnotfound);
    alert.setMessage(R.string.apexmarket);
    alert.setIcon(R.drawable.apex_1);
    alert.setPositiveButton((R.string.yes),
             new DialogInterface.OnClickListener() {
              @Override
            public void onClick(DialogInterface dialog, int id) {
                  final Intent intent = new Intent(Intent.ACTION_VIEW).setData(Uri.parse("market://details?id=com.anddoes.launcher"));
                  startActivity(intent);
              }
             });
            alert.setNegativeButton((R.string.no),
             new DialogInterface.OnClickListener() {
              @Override
            public void onClick(DialogInterface dialog, int id) {
                  return;
              }
             });

            alert.show();

        }
    }

});

以及 fragment_1 的 xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="#f9f9f9"
    android:paddingBottom="15dp" >

    <ScrollView
         android:id="@+id/scrollView1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" android:scrollbars="none"
        android:overScrollMode="never">

        <LinearLayout
            android:id="@+id/linearLayout1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:baselineAligned="false" 
            android:orientation="vertical" >

    <!-- Action -->

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingTop="40dp" >

                <ImageButton
                    android:id="@+id/actiontheme"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentTop="true"
                    android:layout_centerHorizontal="true"
                    android:alpha=".6"
                    android:background="@drawable/btn_default_holo_dark"
                    android:paddingBottom="15dp"
                    android:src="@drawable/alp_1" />

                <TextView
                    android:id="@+id/textView2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/actiontheme"
                    android:layout_centerHorizontal="true"
                    android:alpha=".6"
                    android:fontFamily="sans-serif-light"
                    android:text="@string/action"
                    android:textSize="24dp" />

                <TextView
                    android:id="@+id/textView3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/textView2"
                    android:layout_centerHorizontal="true"
                    android:alpha=".6"
                    android:fontFamily="sans-serif-light"
                    android:text="@string/actiondetails"
                    android:textSize="18sp" />

                <Button
                    android:id="@+id/screens_action"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/textView3"
                    android:layout_centerHorizontal="true"
                    android:alpha=".6"
                    android:background="#00000000"
                    android:text="PREVIEW"
                    android:textColor="@color/blue" />
            </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="10dp"
        android:paddingTop="10dp" >

        <ImageButton
            android:id="@+id/apextheme"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:alpha=".6"
            android:background="@drawable/btn_default_holo_dark"
            android:paddingBottom="15dp"
            android:src="@drawable/apex_1" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/apextheme"
            android:layout_centerHorizontal="true"
            android:alpha=".6"
            android:fontFamily="sans-serif-light"
            android:text="@string/apex"
            android:textSize="24dp" />

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/textView2"
            android:layout_centerHorizontal="true"
            android:alpha=".6"
            android:fontFamily="sans-serif-light"
            android:text="@string/apexdetails"
            android:textSize="18sp" />

        <Button
            android:id="@+id/screens_apex"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/textView3"
            android:layout_centerHorizontal="true"
            android:alpha=".6"
            android:background="#00000000"
            android:text="PREVIEW"
            android:textColor="@color/blue" />

  </RelativeLayout>

    <!-- Nova -->

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="10dp"
        android:paddingTop="10dp" >

        <ImageButton
            android:id="@+id/novatheme"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:alpha=".6"
            android:background="@drawable/btn_default_holo_dark"
            android:paddingBottom="15dp"
            android:src="@drawable/nova_1" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/novatheme"
            android:layout_centerHorizontal="true"
            android:alpha=".6"
            android:fontFamily="sans-serif-light"
            android:text="@string/nova"
            android:textSize="24dp" />

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/textView2"
            android:layout_centerHorizontal="true"
            android:alpha=".6"
            android:fontFamily="sans-serif-light"
            android:text="@string/novadetails"
            android:textSize="18sp" />

        <Button
            android:id="@+id/screens_nova"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/textView3"
            android:layout_centerHorizontal="true"
            android:alpha=".6"
            android:background="#00000000"
            android:text="PREVIEW"
            android:textColor="@color/blue" />

  </RelativeLayout>

    <!-- Adw -->
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="15dp"
        android:paddingTop="15dp" >

        <ImageButton
            android:id="@+id/adwextheme"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:alpha=".6"
            android:background="@drawable/btn_default_holo_dark"
            android:paddingBottom="15dp"
            android:src="@drawable/adwex_1" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/adwextheme"
            android:layout_centerHorizontal="true"
            android:alpha=".6"
            android:fontFamily="sans-serif-light"
            android:text="@string/adwex"
            android:textSize="24dp" />

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/textView2"
            android:layout_centerHorizontal="true"
            android:alpha=".6"
            android:fontFamily="sans-serif-light"
            android:text="@string/adwexdetails"
            android:textSize="18sp" />

        <Button
            android:id="@+id/screens_adwex"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/textView3"
            android:layout_centerHorizontal="true"
            android:alpha=".6"
            android:background="#00000000"
            android:text="PREVIEW"
            android:textColor="@color/blue" />

  </RelativeLayout>

    <!-- go -->
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="15dp"
        android:paddingTop="15dp" >

        <ImageButton
            android:id="@+id/gotheme"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:alpha=".6"
            android:background="@drawable/btn_default_holo_dark"
            android:paddingBottom="15dp"
            android:src="@drawable/go_1" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/gotheme"
            android:layout_centerHorizontal="true"
            android:alpha=".6"
            android:fontFamily="sans-serif-light"
            android:text="@string/go"
            android:textSize="24dp" />

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/textView2"
            android:layout_centerHorizontal="true"
            android:alpha=".6"
            android:fontFamily="sans-serif-light"
            android:text="@string/godetails"
            android:textSize="18sp" />

        <Button
            android:id="@+id/screens_go"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/textView3"
            android:layout_centerHorizontal="true"
            android:alpha=".6"
            android:background="#00000000"
            android:text="PREVIEW"
            android:textColor="@color/blue" />

   </RelativeLayout>    
  </LinearLayout>
 </ScrollView>
</LinearLayout>

编辑:这是 FragmentAdapter.java:

package com.arandompackage.jive;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.viewpagerindicator.IconPagerAdapter;

public class TestFragmentAdapter extends FragmentPagerAdapter implements IconPagerAdapter{
  protected static final String[] CONTENT = new String[] {
        "This", "Is", "A", "Test"   
    };

    private int mCount = 4;

    public TestFragmentAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public int getIconResId(int index) {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public Fragment getItem(int position) {
        Fragment fragment = new Fragment1();
        switch(position){
        case 0:
            fragment = new Fragment1();
            break;
        case 1:
            fragment = new Fragment2();
            break;
        case 2:
            fragment = new Fragment3();
            break;
        case 3:
            fragment = new Fragment4();
            break;
        }
        return fragment;
    }

    @Override
    public int getCount() {
        return mCount;
    }

    @Override
    public CharSequence getPageTitle(int position){
        String title = "";
        switch(position){
        case 0:
            title = "LAUNCHERS";
            break;
        case 1:
            title = "EXTRAS";
            break;
        case 2:
            title = "CONTACT";
            break;
        case 3:
            title = "HELP";
            break;
        }

        return title;
    }

    public void setCount(int count){
        if (count > 0 && count < 10){
            mCount = count;
            notifyDataSetChanged();
        }
    }


}

和TestFragment:

package com.arandompackage.jive;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.TextView;

public class TestFragment extends Fragment{

    private static final String KEY_CONTENT = "TestFragment:Content";

    public static TestFragment newInstance(String content){
        TestFragment fragment = new TestFragment();

        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < 20; i++){
            builder.append(content).append(" ");
        }
        builder.deleteCharAt(builder.length() -1);
        fragment.mContent = builder.toString();

        return fragment;
    }

    private String mContent = "???";

    @Override
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        if ((savedInstanceState != null) && savedInstanceState.containsKey(KEY_CONTENT)){
            mContent = savedInstanceState.getString(KEY_CONTENT);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
        TextView text = new TextView(getActivity());
        text.setGravity(Gravity.CENTER);
        text.setText(mContent);
        text.setTextSize(20 * getResources().getDisplayMetrics().density);
        text.setPadding(20, 20, 20, 20);

        LinearLayout layout = new LinearLayout(getActivity());
        layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
        layout.setGravity(Gravity.CENTER);
        layout.addView(text);
        return layout;
    }

    public void onSavedInstanceState(Bundle outState){
        super.onSaveInstanceState(outState);
        outState.putString(KEY_CONTENT, mContent);
    }
}

这是转折点,主题仍然适用于 Apex Launcher....任何帮助都非常感谢提前!

4

1 回答 1

0

我不记得我的确切答案,但这很可能与库的导出有关。转到项目、属性、构建路径、顺序和导出。正确的顺序是src、gen、android xxx、android私有库、私有库。玩弄检查/取消检查它们。

回家后我会更新答案

编辑: 我的其他答案可以在这里找到:

不幸的是,Google Maps API Demos 已停止 - Google Maps Android API v2

于 2013-07-12T18:25:20.953 回答