Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6905063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:08:17+00:00 2026-05-27T08:08:17+00:00

I recently split my project and created a library project and a main project.

  • 0

I recently split my project and created a library project and a main project. Having a preferences screen that has custom attributes, i removed the preferences with custom attributes from my preferences.xml, put them into their own xml files, included them back into the preferences.xml file and redefined the individual files in the main project (the process is detailed in the answer to another question here.

The project build and run properly. However, I am getting a RuntimeException whenever i try to open the preferences screen. Removing the prefs with custom attrs fixes the problem, so i have traced it back to there. Unfortunately there is no useful information in the exception.

attrs.xml (exists in lib project)

<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="numberpickerPref">
    <attr name="maxValue" format="integer" />
    <attr name="minValue" format="integer" />
</declare-styleable>
</resources>

preferences.xml (also in lib project)

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
    <PreferenceCategory android:title="@string/pref_VibrationSettingsTitle">
        <CheckBoxPreference android:key="@string/pref_vibrateFlagKey" 
            android:title="@string/pref_VibrateTitle" 
            android:summary="@string/pref_VibrateSummary"
            android:defaultValue="false" />

        <include layout="@layout/pref_vibrate_on" />
        <include layout="@layout/pref_vibrate_off" />
    </PreferenceCategory>
</PreferenceScreen>

pref_vibrate_off.xml (defined in both lib and main projects) (only diff is the my namespace, one points to the lib, the other the main project)

<?xml version="1.0" encoding="utf-8"?>
<!-- Stupid workaround because Android still has a bug where custom attributes in a library cause the executable project
problems when building: 
https://stackoverflow.com/questions/4461407/help-with-a-custom-view-attributes-inside-a-android-library-project -->

<com.me.numberpicker.NumberPickerPreference 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:my="http://schemas.android.com/apk/res/com.me.myapp.lib"
    android:key="@string/pref_vibrateOffPeriodKey" 
    android:title="@string/pref_VibrateOffTitle" 
    android:summary="@string/pref_VibrateOffSummary"
    my:maxValue="@string/MaxVibratorOffPeriodInS" 
    my:minValue="@string/MinVibratorOffPeriodInS"
    android:defaultValue="@string/DefaultVibratorOffPeriodInS" />

MyPreferencesActivity.java

public class MegalarmPreferencesActivity extends PreferenceActivity
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.preferences);
    }
}

All the strings are properly defined in the lib project.

If i’m missing anything, let me know please. The preferences were working fine until i split up my project into a lib and main.

Many thanks!
Sean

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:08:17+00:00Added an answer on May 27, 2026 at 8:08 am

    PreferenceActivity.onCreate can throw RuntimeExceptions internally that the IDE might catch (if configured to do so), but they are also caught internally. For instance, a missing layout_width tag in the default theme seems to cause an exception.

    If the RuntimeException is not percolating back to your code don’t worry about it. If it is, could you update your question to include the exception message and stack trace?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently split some code out into an Android library project. I added references
I have a split access 2007 database that has been running fine on a
I recently updated my VS2010 website project from .NET 3.5 to 4.0. Everything was
I've recently needed to write a script that performs an os.fork() to split into
I have a website that recently split into two separate versions, that have fundamental
I have recently created a version control page from my application to manage the
Recently Jeff has posted regarding his trouble with database deadlocks related to reading. Multiversion
Recently our site has been deluged with the resurgence of the Asprox botnet SQL
I'm working on my own open-source project. I've recently released the first workable version
Recently I downloaded Live555 server source code from their site. I tried to compile

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.