尝试编译并启动一个开源的Android应用程序,收到以下错误:错误膨胀类com.android.deskclock.widget.RtlViewPager

时间:2016-05-17 03:26:12

标签: java android android-viewpager open-source android-sdk-2.3

我正在尝试编写" deskclock"来自Android的应用程序,源代码在此处找到:https://android.googlesource.com/platform/packages/apps/DeskClock/

我在Android SDK中创建了一个新项目,添加了文件,并更新了引用以匹配新的包名称。应用程序将编译并安装在模拟器上,但在启动时它几乎立即崩溃,并出现以下错误:

05-16 20:53:37.927 2628-2628/com.mycompanyname.builtinclock E/AndroidRuntime: FATAL EXCEPTION: main
                                                                         Process: com.mycompanyname.builtinclock, PID: 2628
                                                                         java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mycompanyname.builtinclock/com.mycompanyname.builtinclock.deskclock.DeskClock}: android.view.InflateException: Binary XML file line #50: Binary XML file line #50: Error inflating class com.android.deskclock.widget.RtlViewPager

我似乎无法找到导致这种情况发生的原因。我已清理并重建项目无效。

我对上述源代码所做的唯一重大更改是更改公司名称以匹配新的软件包名称,并更新每个引用位置的文件中的名称,以消除它之前提供的所有错误会编译。

另一个重大变化是build.gradle文件,我删除了datetimepicker条目(无法弄清楚如何编译),我在依赖项屏幕上重新添加了appcompat依赖项。

如果有人可以帮助我,或者通过指出代码的错误,或者向我展示编译该软件包的更好方法,我将非常感激!如果这是一个愚蠢的问题,我很抱歉。

请参阅下面的两个已更改的文件。

这是gradle文件:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "com.mycompanyname.builtinclock"
    minSdkVersion 23
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}


dependencies {

compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:gridlayout-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:support-v13:23.4.0'
}

这是AndroidManifest.xml:

 <?xml version="1.0" encoding="utf-8"?>
 <!--
  Copyright (C) 2015 The Android Open Source Project

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or      implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  -->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mycompanyname.builtinclock"
    android:versionCode="410" android:versionName="4.1.0">

<original-package android:name="com.android.alarmclock" />
<original-package android:name="com.android.deskclock" />

<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="23" />

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<!-- WRITE_SETTINGS is required to record the upcoming alarm prior to L -->
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<!-- READ_PHONE_STATE is required to determine when a phone call exists prior to M -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- READ_EXTERNAL_STORAGE is required to play custom ringtones from the SD card prior to M -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<application android:label="@string/app_label"
             android:name=".deskclock.DeskClockApplication"
             android:allowBackup="true"
             android:backupAgent=".deskclock.DeskClockBackupAgent"
             android:fullBackupContent="@xml/backup_scheme"
             android:fullBackupOnly="true"
             android:icon="@mipmap/ic_launcher"
             android:requiredForAllUsers="true"
             android:supportsRtl="true">

    <provider android:name=".deskclock.provider.ClockProvider"
            android:authorities="com.android.mycompanyname.deskclock"
            android:exported="false" />

    <activity android:name=".deskclock.DeskClock"
            android:label="@string/app_label"
            android:theme="@style/DeskClockTheme"
            android:icon="@mipmap/ic_launcher_alarmclock"
            android:launchMode="singleTask">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity-alias android:name="DockClock"
            android:targetActivity=".deskclock.DeskClock"
            android:label="@string/app_label"
            android:theme="@style/DeskClockTheme"
            android:icon="@mipmap/ic_launcher_alarmclock"
            android:launchMode="singleTask"
            android:enabled="@bool/config_dockAppEnabled"
            >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.DESK_DOCK" />
        </intent-filter>
    </activity-alias>

    <activity android:name=".deskclock.settings.SettingsActivity"
            android:label="@string/settings"
            android:theme="@style/SettingsTheme"
            android:taskAffinity=""
            android:excludeFromRecents="true"
            >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
        </intent-filter>
    </activity>

    <activity android:name=".deskclock.worldclock.CitySelectionActivity"
            android:label="@string/cities_activity_title"
            android:theme="@style/CitiesTheme"
            android:taskAffinity=""
            android:excludeFromRecents="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
        </intent-filter>
    </activity>

    <activity android:name=".deskclock.alarms.AlarmActivity"
            android:taskAffinity=""
            android:excludeFromRecents="true"
            android:theme="@style/AlarmAlertFullScreenTheme"
            android:windowSoftInputMode="stateAlwaysHidden"
            android:showOnLockScreen="true" />

    <activity android:name=".deskclock.ScreensaverActivity"
            android:excludeFromRecents="true"
            android:taskAffinity=""
            android:theme="@style/ScreensaverActivityTheme"
            android:configChanges="orientation|screenSize|keyboardHidden|keyboard" />

    <receiver android:name=".deskclock.alarms.AlarmStateManager"
              android:exported="false">
    </receiver>

    <service android:name=".deskclock.alarms.AlarmService"
             android:exported="false">
    </service>

    <activity android:name=".deskclock.HandleApiCalls"
            android:theme="@android:style/Theme.NoDisplay"
            android:excludeFromRecents="true"
            android:launchMode="singleTask"
            android:permission="com.android.alarm.permission.SET_ALARM"
            android:taskAffinity="">
        <intent-filter>
            <action android:name="android.intent.action.SET_ALARM" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.VOICE" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.DISMISS_ALARM" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.VOICE" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SNOOZE_ALARM" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.VOICE" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SHOW_ALARMS" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.VOICE" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SET_TIMER" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.VOICE" />
        </intent-filter>
    </activity>

    <activity-alias android:name="HandleSetAlarm"
        android:targetActivity=".deskclock.HandleApiCalls"
        android:exported="true">
    </activity-alias>

    <activity android:name=".deskclock.HandleDeskClockApiCalls"
        android:theme="@android:style/Theme.NoDisplay"
        android:excludeFromRecents="true"
        android:launchMode="singleTask"
        android:permission="com.android.alarm.permission.SET_ALARM"
        android:taskAffinity="">
        <intent-filter>
            <action android:name="com.android.deskclock.action.SHOW_CLOCK" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.VOICE" />
        </intent-filter>
        <intent-filter>
            <action android:name="com.android.deskclock.action.ADD_CLOCK" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.VOICE" />
        </intent-filter>
        <intent-filter>
            <action android:name="com.android.deskclock.action.DELETE_CLOCK" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.VOICE" />
        </intent-filter>
        <intent-filter>
            <action android:name="com.android.deskclock.action.START_TIMER" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.VOICE" />
        </intent-filter>
        <intent-filter>
            <action android:name="com.android.deskclock.action.RESET_TIMER" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.VOICE" />
        </intent-filter>
        <intent-filter>
            <action android:name="com.android.deskclock.action.PAUSE_TIMER" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.VOICE" />
        </intent-filter>
        <intent-filter>
            <action android:name="com.android.deskclock.action.SHOW_TIMERS" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.VOICE" />
        </intent-filter>
        <intent-filter>
            <action android:name="com.android.deskclock.action.DELETE_TIMER" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.VOICE" />
        </intent-filter>
        <intent-filter>
            <action android:name="com.android.deskclock.action.SHOW_STOPWATCH" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.VOICE" />
        </intent-filter>
        <intent-filter>
            <action android:name="com.android.deskclock.action.START_STOPWATCH" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.VOICE" />
        </intent-filter>
        <intent-filter>
            <action android:name="com.android.deskclock.action.PAUSE_STOPWATCH" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.VOICE" />
        </intent-filter>
        <intent-filter>
            <action android:name="com.android.deskclock.action.LAP_STOPWATCH" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.VOICE" />
        </intent-filter>
        <intent-filter>
            <action android:name="com.android.deskclock.action.RESET_STOPWATCH" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.VOICE" />
        </intent-filter>
    </activity>

    <receiver android:name="deskclock.AlarmInitReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <action android:name="android.intent.action.TIME_SET" />
            <action android:name="android.intent.action.TIMEZONE_CHANGED" />
            <action android:name="android.intent.action.LOCALE_CHANGED" />
            <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
        </intent-filter>
    </receiver>

    <receiver
        android:name="com.mycompanyname.builtinclock.alarmclock.AnalogAppWidgetProvider"
        android:icon="@mipmap/ic_launcher_alarmclock"
        android:label="@string/analog_gadget">
        <intent-filter>
            <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
        </intent-filter>

        <meta-data
            android:name="android.appwidget.oldName"
            android:value="com.android.deskclock.AnalogAppWidgetProvider"/>
        <meta-data
            android:name="android.appwidget.provider"
            android:resource="@xml/analog_appwidget"/>
    </receiver>

    <receiver
        android:name="com.mycompanyname.builtinclock.alarmclock.DigitalAppWidgetProvider"
        android:icon="@mipmap/ic_launcher_alarmclock"
        android:label="@string/digital_gadget">
        <intent-filter>
            <action android:name="android.intent.action.TIME_SET"/>
            <action android:name="android.intent.action.SCREEN_ON"/>
            <action android:name="android.intent.action.DATE_CHANGED"/>
            <action android:name="android.intent.action.LOCALE_CHANGED"/>
            <action android:name="android.intent.action.TIMEZONE_CHANGED"/>
            <action android:name="com.android.deskclock.DIGITAL_WIDGET_CHANGED"/>
            <action android:name="com.android.deskclock.ON_QUARTER_HOUR"/>
            <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
            <action android:name="android.app.action.NEXT_ALARM_CLOCK_CHANGED"/>
        </intent-filter>
        <meta-data
            android:name="android.appwidget.provider"
            android:resource="@xml/digital_appwidget"/>
    </receiver>

    <service android:name="com.mycompanyname.builtinclock.alarmclock.DigitalAppWidgetService"
         android:permission="android.permission.BIND_REMOTEVIEWS"
         android:exported="false" />

    <!-- Dream (screensaver) implementation -->
    <service android:name="deskclock.Screensaver"
        android:exported="true"
        android:label="@string/app_label"
        android:permission="android.permission.BIND_DREAM_SERVICE">
        <intent-filter>
            <action android:name="android.service.dreams.DreamService" />
            <action android:name="android.app.action.NEXT_ALARM_CLOCK_CHANGED" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
        <meta-data
            android:name="android.service.dream"
            android:resource="@xml/dream_info" />
    </service>

    <!-- Settings activity for screensaver -->
    <activity android:name=".deskclock.settings.ScreensaverSettingsActivity"
            android:label="@string/screensaver_settings"
            android:theme="@style/SettingsTheme"
            android:taskAffinity=""
            android:excludeFromRecents="true"
            android:exported="true"
            >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
        </intent-filter>
    </activity>

    <activity
        android:name=".deskclock.AlarmSelectionActivity"
        android:label="@string/dismiss_alarm"
        android:theme="@android:style/Theme.Holo.Light.Dialog.NoActionBar"/>

    <!-- This activity displays only the timers that have expired with only a reset button
     present. This makes the activity appropriate for display above the lock screen so that
     users have the limited ability to silence expired timers but nothing else. -->
    <activity android:name=".deskclock.timer.ExpiredTimersActivity"
            android:excludeFromRecents="true"
            android:theme="@style/ExpiredTimersActivityTheme"
            android:launchMode="singleInstance"
            android:showOnLockScreen="true"
            android:taskAffinity=""
            android:configChanges="screenSize|keyboardHidden|keyboard|navigation"/>

    <!-- Legacy broadcast receiver that honors old scheduled timers across app upgrade. -->
    <receiver android:name="deskclock.timer.TimerReceiver"
              android:exported="false">
        <intent-filter>
            <action android:name="times_up" />
        </intent-filter>
    </receiver>

    <service android:name=".deskclock.timer.TimerService"
             android:exported="false"
             android:description="@string/timer_service_desc">
    </service>

    <service android:name=".deskclock.stopwatch.StopwatchService"
            android:exported="false"
            android:description="@string/stopwatch_service_desc">
    </service>
</application>

1 个答案:

答案 0 :(得分:1)

在布局xml文件中,您仍在使用 com.android.deskclock.widget.RtlViewPager 类。当您更改包名称时,您还需要在xml文件中更改相同的内容