android.content.res.Resources$NotFoundException но необычный

Снова привет! у меня очень странная ошибка при запуске прилоежния(занимаюсь его декомпиляцией и модификацией) сама ошибка из logcat:

02-02 21:34:14.004 22403 22403 E AndroidRuntime: FATAL EXCEPTION: main
02-02 21:34:14.004 22403 22403 E AndroidRuntime: Process: com.craftvalley.masterblockpe, PID: 22403
02-02 21:34:14.004 22403 22403 E AndroidRuntime: java.lang.RuntimeException: Unable to create service com.wrapper.proxyapplication.MyService: android.content.res.Resources$NotFoundException: Resource ID #0x7f0b0020
02-02 21:34:14.004 22403 22403 E AndroidRuntime:    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3320)
02-02 21:34:14.004 22403 22403 E AndroidRuntime:    at android.app.ActivityThread.-wrap5(ActivityThread.java)
02-02 21:34:14.004 22403 22403 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1662)
02-02 21:34:14.004 22403 22403 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:110)
02-02 21:34:14.004 22403 22403 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:203)
02-02 21:34:14.004 22403 22403 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:6361)
02-02 21:34:14.004 22403 22403 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
02-02 21:34:14.004 22403 22403 E AndroidRuntime:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
02-02 21:34:14.004 22403 22403 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
02-02 21:34:14.004 22403 22403 E AndroidRuntime: Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f0b0020
02-02 21:34:14.004 22403 22403 E AndroidRuntime:    at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:198)
02-02 21:34:14.004 22403 22403 E AndroidRuntime:    at android.content.res.Resources.loadXmlResourceParser(Resources.java:2330)
02-02 21:34:14.004 22403 22403 E AndroidRuntime:    at android.content.res.Resources.getLayout(Resources.java:1268)
02-02 21:34:14.004 22403 22403 E AndroidRuntime:    at android.view.LayoutInflater.inflate(LayoutInflater.java:424)
02-02 21:34:14.004 22403 22403 E AndroidRuntime:    at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
02-02 21:34:14.004 22403 22403 E AndroidRuntime:    at com.wrapper.proxyapplication.MyService.addOverlayView(MyService.java:106)
02-02 21:34:14.004 22403 22403 E AndroidRuntime:    at com.wrapper.proxyapplication.MyService.onCreate(MyService.java:49)
02-02 21:34:14.004 22403 22403 E AndroidRuntime:    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3310)
02-02 21:34:14.004 22403 22403 E AndroidRuntime:    ... 8 more

Убил на это уже несколько часов, результатов ноль.. Выяснил только что приложение не может найти ресурс 0x7f0b0020 (banner_layout), хотя он везде прописан (и в R тоже) и что ошибку вызывает MyService.java, его писал я, приложу его исходник:

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.os.IBinder;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.widget.FrameLayout;
import android.widget.Toast;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;

/**
 * Created by matt on 08/08/2016.
 */

public class MyService extends Service {

    private static final String TAG = MyService.class.getSimpleName();

    private WindowManager windowManager;

    private View floatyView;

    private AdView mAdView;

    protected BaseActivity nMyApplication;
    protected MainMainActivity mact;

    @Override
    public IBinder onBind(Intent intent) {

        return null;
    }
    @Override
    public void onCreate() {

        super.onCreate();

        windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);

        addOverlayView();

        Context context = getApplicationContext();
        CharSequence text = "Hello toast!";
        int duration = Toast.LENGTH_SHORT;

        Toast toast = Toast.makeText(context, text, duration);
        toast.show();

    }

    private void addOverlayView() {

        final WindowManager.LayoutParams params;
        int layoutParamsType;

        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
            layoutParamsType = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
        }
        else {
            layoutParamsType = LayoutParams.TYPE_PHONE;
        }

        params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.WRAP_CONTENT,
                layoutParamsType,
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
                PixelFormat.TRANSLUCENT);

        params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP;
        params.x = 0;
        params.y = 0;


        FrameLayout interceptorLayout = new FrameLayout(this) {

            @Override
            public boolean dispatchKeyEvent(KeyEvent event) {
                nMyApplication = (BaseActivity) getApplicationContext();
                if (!nMyApplication.isAppInForeground()){
                    onDestroy();
                }
                // Only fire on the ACTION_DOWN event, or you'll get two events (one for _DOWN, one for _UP)
                if (event.getAction() == KeyEvent.ACTION_DOWN) {

                    // Check if the HOME button is pressed
                    if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {


                        // As we've taken action, we'll return true to prevent other apps from consuming the event as well
                        return true;
                    }
                }

                // Otherwise don't intercept the event
                return super.dispatchKeyEvent(event);
            }
        };

        LayoutInflater inflater = ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE));

        if (inflater != null) {
            floatyView = inflater.inflate(R.layout.banner_layout, interceptorLayout);
            windowManager.addView(floatyView, params);



            mAdView = floatyView.findViewById(R.id.adView);
            mAdView.loadAd(new AdRequest.Builder().addTestDevice("F369F48F5F61393A5B37B64753E2C9A5")
                    .build());
        }
        else {
            Log.e("SAW-example", "Layout Inflater Service is null; can't inflate and display R.layout.floating_view");
        }

    }



    @Override
    public void onDestroy() {

        super.onDestroy();

        if (floatyView != null) {

            windowManager.removeView(floatyView);

            floatyView = null;
        }
    }

}

Предупреждаю, недоработал там ещё достаточно, меня интересует эта проблема ( для корректной работы сервиса включите отображение поверх экрана, без этого сервис не работает и следовательно ошибки нет) Прошу прощения за прямые вставки кода, пастебин почему-то не работает


Ответы (0 шт):